import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;

public class Main {

	private static int[] a;

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int s = Integer.parseInt(br.readLine());
		br.close();

		Set<Integer> aSet = new HashSet<Integer>();
		aSet.add(s);
		a = new int[1000001];
		a[1] = s;
		for (int i = 2; i <=1000000; i++) {
			a[i] = ai(i);
			boolean flg = aSet.add(a[i]);
			if (!flg) {
//				for (int j = 0; j <= i; j++) {
//					System.out.print(a[j] + " ");
//				}
//				System.out.println();
				System.out.println(i);
				break;
			}
		}
	}

	private static int fn (int n) {
		if (n % 2 == 0) {
			return n / 2;
		} else {
			return 3 * n + 1;
		}
	}

	private static int ai (int i) {
		if (i == 1) {
			return a[1];
		} else {
			return fn(ai(i - 1));
		}
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.HashSet; HashSet java.util import java.util.Set; Set java.util public class Main {

	private static int[] a;

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int s = Integer.parseInt(br.readLine());
		br.close();

		Set<Integer> aSet = new HashSet<Integer>();
		aSet.add(s);
		a = new int[1000001];
		a[1] = s;
		for (int i = 2; i <=1000000; i++) {
			a[i] = ai(i);
			boolean flg = aSet.add(a[i]);
			if (!flg) {
//				for (int j = 0; j <= i; j++) {
//					System.out.print(a[j] + " ");
//				}
//				System.out.println();
				System.out.println(i);
				break;
			}
		}
	}

	private static int fn (int n) {
		if (n % 2 == 0) {
			return n / 2;
		} else {
			return 3 * n + 1;
		}
	}

	private static int ai (int i) {
		if (i == 1) {
			return a[1];
		} else {
			return fn(ai(i - 1));
		}
	}
} Main private static int[] a; a public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int s = Integer.parseInt(br.readLine());
		br.close();

		Set<Integer> aSet = new HashSet<Integer>();
		aSet.add(s);
		a = new int[1000001];
		a[1] = s;
		for (int i = 2; i <=1000000; i++) {
			a[i] = ai(i);
			boolean flg = aSet.add(a[i]);
			if (!flg) {
//				for (int j = 0; j <= i; j++) {
//					System.out.print(a[j] + " ");
//				}
//				System.out.println();
				System.out.println(i);
				break;
			}
		}
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int s = Integer.parseInt(br.readLine());
		br.close();

		Set<Integer> aSet = new HashSet<Integer>();
		aSet.add(s);
		a = new int[1000001];
		a[1] = s;
		for (int i = 2; i <=1000000; i++) {
			a[i] = ai(i);
			boolean flg = aSet.add(a[i]);
			if (!flg) {
//				for (int j = 0; j <= i; j++) {
//					System.out.print(a[j] + " ");
//				}
//				System.out.println();
				System.out.println(i);
				break;
			}
		}
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) int s = Integer.parseInt(br.readLine()); s Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br br.close() br.close br Set<Integer> aSet = new HashSet<Integer>(); aSet new HashSet<Integer>() aSet.add(s) aSet.add aSet s a = new int[1000001] a new int[1000001] 1000001 a[1] = s a[1] a 1 s for (int i = 2; i <=1000000; i++) {
			a[i] = ai(i);
			boolean flg = aSet.add(a[i]);
			if (!flg) {
//				for (int j = 0; j <= i; j++) {
//					System.out.print(a[j] + " ");
//				}
//				System.out.println();
				System.out.println(i);
				break;
			}
		} int i = 2; int i = 2; i 2 i <=1000000 i 1000000 i++ i++ i {
			a[i] = ai(i);
			boolean flg = aSet.add(a[i]);
			if (!flg) {
//				for (int j = 0; j <= i; j++) {
//					System.out.print(a[j] + " ");
//				}
//				System.out.println();
				System.out.println(i);
				break;
			}
		} {
			a[i] = ai(i);
			boolean flg = aSet.add(a[i]);
			if (!flg) {
//				for (int j = 0; j <= i; j++) {
//					System.out.print(a[j] + " ");
//				}
//				System.out.println();
				System.out.println(i);
				break;
			}
		} a[i] = ai(i) a[i] a i ai(i) ai i boolean flg = aSet.add(a[i]); flg aSet.add(a[i]) aSet.add aSet a[i] a i if (!flg) {
//				for (int j = 0; j <= i; j++) {
//					System.out.print(a[j] + " ");
//				}
//				System.out.println();
				System.out.println(i);
				break;
			} !flg flg {
//				for (int j = 0; j <= i; j++) {
//					System.out.print(a[j] + " ");
//				}
//				System.out.println();
				System.out.println(i);
				break;
			} System.out.println(i) System.out.println System.out System System.out i break; String[] args args private static int fn (int n) {
		if (n % 2 == 0) {
			return n / 2;
		} else {
			return 3 * n + 1;
		}
	} fn {
		if (n % 2 == 0) {
			return n / 2;
		} else {
			return 3 * n + 1;
		}
	} if (n % 2 == 0) {
			return n / 2;
		} else {
			return 3 * n + 1;
		} n % 2 == 0 n % 2 n 2 0 {
			return n / 2;
		} return n / 2; n / 2 n 2 {
			return 3 * n + 1;
		} return 3 * n + 1; 3 * n + 1 3 * n 3 n 1 int n n private static int ai (int i) {
		if (i == 1) {
			return a[1];
		} else {
			return fn(ai(i - 1));
		}
	} ai {
		if (i == 1) {
			return a[1];
		} else {
			return fn(ai(i - 1));
		}
	} if (i == 1) {
			return a[1];
		} else {
			return fn(ai(i - 1));
		} i == 1 i 1 {
			return a[1];
		} return a[1]; a[1] a 1 {
			return fn(ai(i - 1));
		} return fn(ai(i - 1)); fn(ai(i - 1)) fn ai(i - 1) ai i - 1 i 1 int i i public class Main {

	private static int[] a;

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int s = Integer.parseInt(br.readLine());
		br.close();

		Set<Integer> aSet = new HashSet<Integer>();
		aSet.add(s);
		a = new int[1000001];
		a[1] = s;
		for (int i = 2; i <=1000000; i++) {
			a[i] = ai(i);
			boolean flg = aSet.add(a[i]);
			if (!flg) {
//				for (int j = 0; j <= i; j++) {
//					System.out.print(a[j] + " ");
//				}
//				System.out.println();
				System.out.println(i);
				break;
			}
		}
	}

	private static int fn (int n) {
		if (n % 2 == 0) {
			return n / 2;
		} else {
			return 3 * n + 1;
		}
	}

	private static int ai (int i) {
		if (i == 1) {
			return a[1];
		} else {
			return fn(ai(i - 1));
		}
	}
} public class Main {

	private static int[] a;

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int s = Integer.parseInt(br.readLine());
		br.close();

		Set<Integer> aSet = new HashSet<Integer>();
		aSet.add(s);
		a = new int[1000001];
		a[1] = s;
		for (int i = 2; i <=1000000; i++) {
			a[i] = ai(i);
			boolean flg = aSet.add(a[i]);
			if (!flg) {
//				for (int j = 0; j <= i; j++) {
//					System.out.print(a[j] + " ");
//				}
//				System.out.println();
				System.out.println(i);
				break;
			}
		}
	}

	private static int fn (int n) {
		if (n % 2 == 0) {
			return n / 2;
		} else {
			return 3 * n + 1;
		}
	}

	private static int ai (int i) {
		if (i == 1) {
			return a[1];
		} else {
			return fn(ai(i - 1));
		}
	}
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;

public class Main {

	private static int[] a;

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int s = Integer.parseInt(br.readLine());
		br.close();

		Set<Integer> aSet = new HashSet<Integer>();
		aSet.add(s);
		a = new int[1000001];
		a[1] = s;
		for (int i = 2; i <=1000000; i++) {
			a[i] = ai(i);
			boolean flg = aSet.add(a[i]);
			if (!flg) {
//				for (int j = 0; j <= i; j++) {
//					System.out.print(a[j] + " ");
//				}
//				System.out.println();
				System.out.println(i);
				break;
			}
		}
	}

	private static int fn (int n) {
		if (n % 2 == 0) {
			return n / 2;
		} else {
			return 3 * n + 1;
		}
	}

	private static int ai (int i) {
		if (i == 1) {
			return a[1];
		} else {
			return fn(ai(i - 1));
		}
	}
}
