Codeforces Round 218 (Div. 2)
B
Fox Dividing Cheese
Codeforces
1300
原题
← AC →
翻译中…

Two little greedy bears have found two pieces of cheese in the forest of weight $*a*$ and $*b*$ grams, correspondingly. The bears are so greedy that they are ready to fight for the larger piece. That's where the fox comes in and starts the dialog: "Little bears, wait a little, I want to make your pieces equal" "Come off it fox, how are you going to do that?", the curious bears asked. "It's easy", said the fox. "If the mass of a certain piece is divisible by two, then I can eat exactly a half of the piece. If the mass of a certain piece is divisible by three, then I can eat exactly two-thirds, and if the mass is divisible by five, then I can eat four-fifths. I'll eat a little here and there and make the pieces equal".

翻译中…

The little bears realize that the fox's proposal contains a catch. But at the same time they realize that they can not make the two pieces equal themselves. So they agreed to her proposal, but on one condition: the fox should make the pieces equal as quickly as possible. Find the minimum number of operations the fox needs to make pieces equal.

翻译中…

Input

翻译中…

The first line contains two space-separated integers $*a*$ and $*b*$ ($1 ≤ *a*, *b* ≤ 10^{9}$).

翻译中…

Output

翻译中…

If the fox is lying to the little bears and it is impossible to make the pieces equal, print -1. Otherwise, print the required minimum number of operations. If the pieces of the cheese are initially equal, the required number is 0.

翻译中…

样例

Input #1
15 20
Output #1
3
InputCopy OutputCopy
Input #2
14 8
Output #2
-1
InputCopy OutputCopy
Input #3
6 6
Output #3
0
InputCopy OutputCopy
题目信息
题号
371B
时间限制
1 s
内存限制
256 MB
标签
数学
数论

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。