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