# 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], t[N]; int a[N], b[N]; void solve () { int len = strlen(s); for (int i = 0; i < len; i ++ ) a[len - i - 1] = s[i] - '0'; int k; for (k = 0; len; ) { for (int i = len; i >= 1; i -- ) a[i - 1] += a[i] % 2 * 10, a[i] /= 2; b[k ++ ] = a[0] % 2; a[0] /= 2; while (len && !a[len - 1]) len -- ; } a[k] = 0; for (int i = 0; i < k; i ++ ) t[k - i - 1] = b[i] + '0'; } signed main () { // freopen ("double.in", "r", stdin); freopen ("double.out", "w", stdout); scanf ("%s", s); solve (); int len = strlen (t); ll ans = 0; for (int i = 0; i < len; i ++ ) ans += t[i] - '0'; printf ("%lld\n", ans); return 0; }