public void solve() throws IOException {
    int a = nextInt();
    int b = nextInt();
    State init = new State(a, b, 0);
    ArrayList<State> queue = new ArrayList<State>();
    queue.add(init);
    while (queue.size() > 0) {
      State cur = queue.remove(0);
      int max = Math.max(cur.a, cur.b);
      int min = Math.min(cur.a, cur.b);
      if (max == min) {
        System.out.println(cur.count);
        return;
      }
      if (max % 5 == 0)
        queue.add(new State(max / 5, min, cur.count + 1));
      if (max % 3 == 0)
        queue.add(new State(max / 3, min, cur.count + 1));
      if (max % 2 == 0)
        queue.add(new State(max / 2, min, cur.count + 1));
    }
    System.out.println(-1);
  }