import sys input = sys.stdin.readline from fractions import Fraction from math import gcd X=input().strip() ANS=0 X=Fraction(X) a=X.numerator b=X.denominator while True: ANS+=1 a,b=b,a if b==0: break a=a%b #print(a,b) print(ANS-1)