a,b=input().split(".") b=b+"0"*(9-len(b)) a=int(a) b=int(b) c=a*10**9+b d=10**9 cnt=0 while True: if c==0: break cnt+=1 c,d=d,c c%=d print(cnt)