import java.io.*; import java.util.*; public class Main_yukicoder634 { private static Scanner sc; private static Printer pr; private static void solve() { int n = sc.nextInt(); Set tr = new HashSet<>(); for (int i = 1; i * (i + 1) / 2 <= n; i++) { int tmp = i * (i + 1) / 2; tr.add(tmp); } if (tr.contains(n)) { pr.println(1); } else { for (int e : tr) { if (tr.contains(n - e)) { pr.println(2); return; } } pr.println(3); } } // --------------------------------------------------- public static void main(String[] args) { sc = new Scanner(System.in); pr = new Printer(System.out); solve(); pr.close(); sc.close(); } private static class Printer extends PrintWriter { Printer(PrintStream out) { super(out); } } }