X, Y = gets.split.map &:to_i h = Hash.new(0) ans = 0 for y in 1..Math.sqrt(Y).floor do for x in 0..Math.sqrt(Y).floor do rr = y**2 + x**2 if X <= rr && rr <= Y then h[rr] += 1 ans = [ans, h[rr]].max end end end puts ans*4