# include using namespace std; typedef long long ll; const int N = 1000010; string n; ll a[N], b[N], c[N]; void print(ll x[]) { for (int i = x[0]; i >= 1; i--) putchar(char(x[i] + '0')); putchar('\n'); } void chg(string s, ll x[]) { ll len; len = s.size(); x[0] = len; for (int i = 0; i < len; i++) x[len - i] = s[i] - '0'; } void ms(ll x[], ll y[], ll z[]) { ll l1, l2; l1 = x[0], l2 = y[0]; ll r; r = 0; for (int i = 1; i <= l1; i++) { ll tmp; tmp = x[i] - y[i] - r; r = (tmp < 0) ? 1 : 0; tmp += 10 * (tmp < 0); z[i] = tmp; } z[0] = l1; while (z[z[0]] == 0) z[0]--; } void div(ll a[], ll b, ll c[]) { string r; r = ""; ll d; d = 0; if (a[0] == 1 && a[1] == 1) {c[0] = 1, c[1] = 0; return;} if (a[0] == 1 && !a[1]) {c[0] = 1, c[1] = 0; return;} for (int i = a[0]; i >= 1; i--) { r += (d * 10 + a[i]) / b + '0'; d = (d * 10 + a[i]) % b; } c[0] = r.size(); for (int i = c[0]; i >= 1; i--) c[i] = r[c[0] - i] - '0'; while (!c[c[0]]) c[0]--; } int main() { cin >> n; chg(n, a); chg(n, b); for (int i = 1; i <= 3320500; i++) { if (b[0] == 1 && !b[1]) break; div(b, 2, b); ms(a, b, a); } print(a); return 0; }