PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GL0000013. Nhân 2 hoặc chia 6 (Multiply by 2, divide by 6)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Nhân 2 hoặc chia 6 (Multiply by 2, divide by 6)

Multiply by 2, divide by 6

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Starting from a positive integer nn, you may either multiply the current value by 22, or divide it by 66 when exactly divisible. Find the minimum number of operations to reach 11, or output -1 if impossible.

Input

One line containing nn.

Output

Print the minimum number of moves or -1.

Subtasks

  • Subtask 1 (20 points): 1≤n≤1001 \le n \le 100
  • Subtask 2 (30 points): 1≤n≤1061 \le n \le 10^{6}
  • Subtask 3 (50 points): 1≤n≤1091 \le n \le 10^{9}

Examples

Input

3

Output

2

Explanation

Multiply 33 by 22 to obtain 66, then divide by 66 to reach 11 in two operations.