#include <iostream>
#include <algorithm>
using namespace std;

int main()
{   string T;
    string S;
    cin >> T;
    cin >> S;
    if(S.length() == 1){
        size_t n = count(T.begin(), T.end(), 'a');
        cout << n;
    }
    return 0;
}