def calc(x) (1..100000).bsearch {|k| x < k*(k+1)/2 }-1 end def bye(x) p x exit end n = gets.to_i 0.upto(4500) do |k| rk = k*(k+1)/2 bye 1 if rk == n (k+1).upto(4500) do |l| rl = l*(l+1)/2 bye 2 if rl + rk == n end end bye 3