#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 5;   const int MOD = 1e9 + 7;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);     string s;     cin >> s;     sort(s.begin(), s.end());     long long int sz = (int)s.size();     int i = 0, ct = 0;     while (s[i] ==  a ) {       ct++;       i++;     }     while (sz && ct * 2 <= sz) {       char ch = s.back();       sz--;       if (ch ==  a ) ct--;     }     cout << sz;     return 0;   }   