import java.io.*; import java.util.*; public class Main_yukicoder642_1 { private static Scanner sc; private static Printer pr; private static void solve() { int n = sc.nextInt(); Map dp = new HashMap<>(); dp.put((long)n, 0); Queue q = new ArrayDeque<>(); q.add((long)n); while (!q.isEmpty()) { long e = q.remove(); if (e == 1) { pr.println(dp.get(e)); return; } if (e > 1) { if (e % 2 == 0 && !dp.containsKey(e / 2)) { q.add(e / 2); dp.put(e / 2, dp.get(e) + 1); } if (!dp.containsKey(e + 1)) { q.add(e + 1); dp.put(e + 1, dp.get(e) + 1); } } } } // --------------------------------------------------- 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); } } }