def max(a,b); a > b ? a : b; end X, Y = gets.split.map(&:to_i) R = Math.sqrt(Y).ceil C = Hash.new(0) fmax = 0 (1 .. R).each do |x| x2 = x ** 2 break if x2 > Y ymin = (0 .. R).bsearch{|y| x ** 2 + y ** 2 >= X } ymax = (0 .. R).bsearch{|y| x ** 2 + y ** 2 > Y } (ymin .. ymax).each do |y| r2 = x ** 2 + y ** 2 unless r2 < X || r2 > Y C[r2] += 1 fmax = max(fmax, C[r2]) end end end puts fmax * 4