#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int n = s.size();
  int a[26] = {0};
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    if (s[i] - 'a' < 0 && s[i] == 'B')
      cnt++;
    else if (s[i] - 'a' >= 0)
      a[s[i] - 'a']++;
  }
  cnt = min(cnt, min(a[0] / 2,
                     min(a[1], min(a[11], min(a[17], min(a[18], a[20] / 2))))));
  cout << cnt << endl;
  return 0;
}
