public static void main(String[] args) {

		int[] chainLength = new int[1000000];
		for (int i = 0; i < chainLength.length; i++)
			chainLength[i] = 0;
		chainLength[1] = 1;

		long next;
		for (int i = 2; i < chainLength.length; i++) {
			next = i;
			int length = 0;
			while (next != 1 && next >= i) {
				if (next % 2 == 0)
					next /= 2;
				else
					next = next * 3 + 1;
				length++;
			}
			chainLength[i] = length + chainLength[(int) next];
		}
		int max = 0;
		for(int i = 0; i < chainLength.length; i++)
			if (chainLength[i] > chainLength[max])
				max = i;
		System.out.println(max);
		// Solution: 837799
	}