#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, f, i;
  cin >> n;
  string arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  for (int i = 0; i < n; i++) {
    if (arr[i] == "a") a++;
    if (arr[i] == "f") f++;
    if (arr[i] == "i") i++;
  }
  if (i > 1 || (i == 0 && a == 0))
    cout << "0";
  else
    cout << a + i;
  return 0;
}
