from decimal import * ss = input() d = Decimal(ss) n, m = d.as_integer_ratio() ans = 0 while n : ans += 1 n, m = m%n, n print(ans)