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