import java.math.BigInteger; import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); BigInteger n = sc.nextBigInteger(); BigInteger b = sc.nextBigInteger(); sc.close(); try { BigInteger ans = n.modInverse(b); System.out.println(ans); } catch (Exception e) { System.out.println("NaN"); } } }