N = gets.to_i ok = 1 ng = N while (ok - ng).abs >= 2 x = (ok + ng) / 2 if Rational(N, x) - Rational(N, x + 1) > 1 ok = x else ng = x end end puts ok + Rational(N, ok + 1).to_i