#include using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; int main() { cin.tie(nullptr)->sync_with_stdio(false); ll x = 0, y = 1; { string s; cin >> s; bool flg = false; for (char c : s) { if (c == '.') { flg = true; continue; } assert(isdigit(c)); x = x * 10 + (c - '0'); if (flg) y *= 10; } swap(x, y); } int cnt = 0; while (true) { cnt++; // cerr << format("{}: {}/{}", cnt, x, y); x %= y; if (x == 0) { // cerr << format(" -> {}/{}\n", x, y); break; } ll g = gcd(x, y); x /= g, y /= g; swap(x, y); // cerr << format(" -> {}/{}\n", x, y); } cout << cnt << '\n'; return 0; }