/*
 * 0158.cpp
 *
 *  Created on: 2011/07/27
 *      Author: isa
 */

#include <iostream>
#include <cstring>

using namespace std;

int m[1000001];

void func(long long num, int times){
	if(num > 1000000 || m[num] != -1) return;
	m[num] = times;
	func(num*2,times+1);
	if((num-1)%3 == 0 && ((num-1)/3)%2 == 1){
		func((num-1)/3, times+1);
	}
}

int main(void){
	int n;
	memset(m,-1,sizeof(m));
	m[1] = 0;
	func(2,1);
	while(cin >> n && n) cout << m[n] << endl;
}