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