N,B=map(int,input().split()) try:print(pow(N,-1,B)) except:print("NaN")