# include using namespace std; typedef long long ll; //# define int long long # define lc u << 1 # define rc u << 1 | 1 # define fi first # define se second const int N = 1000005; char s[N]; vector add (vector a, vector b) { int la = a.size (), lb = b.size (); if (la < lb) return add (b, a); reverse (a.begin (), a.end ()); reverse (b.begin (), b.end ()); vector c; int t = 0; for (int i = 0; i < la; i ++ ) { t += a[i]; if (i < lb) t += b[i]; c.push_back (t % 10); t /= 10; } if (t) c.push_back(t); reverse (c.begin (), c.end ()); return c; } int cmp (vector a, vector b) { int la = a.size (), lb = b.size (); if (la != lb) return 1; for (int i = 0; i < la; i ++ ) { if (a[i] != b[i]) return a[i] > b[i]; } return 0; } vector sub (vector a, vector b) { int la = a.size (), lb = b.size (); reverse (a.begin (), a.end ()); reverse (b.begin (), b.end ()); vector c; int t = 0; for (int i = 0; i < la; i ++ ) { t = a[i] - t; if (i < lb) t -= b[i]; c.push_back ((t + 10) % 10); if (t < 0) t = 1; else t = 0; } while (c.size () > 1 && !c.back ()) c.pop_back (); reverse (c.begin (), c.end ()); return c; } vector mul (vector a, int b) { int la = a.size (); reverse (a.begin (), a.end ()); vector c; int t = 0; for (int i = 0; i < la || t; i ++ ) { if (i < la) t += a[i] * b; c.push_back (t % 10); t /= 10; } while (c.size () > 1 && !c.back ()) c.pop_back (); reverse (c.begin (), c.end ()); return c; } vector div (vector a, int b, int &r) { int la = a.size (); reverse (a.begin (), a.end ()); vector c; for (int i = la - 1; i >= 0; i -- ) { r = r * 10 + a[i]; c.push_back (r / b); r %= b; } reverse (c.begin (), c.end ()); while (c.size () > 1 && !c.back ()) c.pop_back (); reverse (c.begin (), c.end ()); return c; } signed main () { // freopen ("double.in", "r", stdin); freopen ("double.out", "w", stdout); scanf ("%s", s + 1); int len = strlen (s + 1); vector n; for (int i = 1; i <= len; i ++ ) n.push_back (s[i] - '0'); vector tmp = n, zero, ans = n; zero.push_back (0); int r = 0; while (cmp (tmp, zero)) { r = 0; tmp = div (tmp, 2, r); ans = sub (ans, tmp); } for (int i = 0; i < ans.size (); i ++ ) printf ("%d", ans[i]); return 0; }