#include <bits/stdc++.h>   using namespace std;   long long int x[1000007], y[1000007], z[1000007], n;   string s, S;   vector<long long int> v;   int main() {     {       long long int a = 0, b = 0, c = 0, d, e, f, g, i, j, k, l, m, p, q, r, u, w,                     t, tc, in, mod, loc, diff, val, sz, lo, hi, mid,                     mn = 2134567891, mx = 0, sum = 0, ans = 0;       cin >> s;       l = s.size();       for (i = 0; i < l; i++)         if (s[i] ==  a ) a++;       if (a * 2 > l)         cout << l << endl;       else         cout << a * 2 - 1 << endl;     }     return 0;   }   