import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static ArrayList retrievePrimeFactors(long n) { ArrayList result = new ArrayList(); long copyOfInput = n; while (copyOfInput%2 == 0) { result.add((long)2); copyOfInput /= 2; } //copyOfInput must be odd at this point for (long i = 3; i <= Math.sqrt(copyOfInput); i = i+2) { // While i divides n, print i and divide n while (copyOfInput%i == 0) { result.add(i); copyOfInput = copyOfInput/i; } } // This condition is to handle the case when n // is a prime number greater than 2 if (copyOfInput > 2) result.add(copyOfInput); return result; } static long moves(long n) { ArrayList primefactors = retrievePrimeFactors(n); Collections.sort(primefactors, Collections.reverseOrder()); long count=1; long num=1; for (int i=0; i