#include <iostream>

using namespace std;

int x;
int cnt = 0;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> x;

	while (true)
	{
		if (x == 1)
		{
			break;
		}
		else if (x % 3 == 0)
		{
			x /= 3;
			cnt++;
		}
		else if ((x - 1) % 3 == 0)
		{
			x -= 1;
			cnt++;
		}
		else if (x % 2 == 0)
		{
			x /= 2;
			cnt++;
		}
	}
	cout << cnt;
}


