#include <bits/stdc++.h>
using namespace std;
char a[300000];
int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    scanf("%s", a);
    int len = strlen(a);
    bool flag = false;
    int cnt = 0;
    for (int i = 0; i < len; ++i) {
      if (a[i] == 'A' && cnt >= 0)
        cnt++;
      else if (a[i] == 'I') {
        if (!flag)
          flag = true;
        else {
          flag = false;
          cnt = -1;
        }
      }
    }
    if (cnt < 0) cnt = 0;
    printf("%d\n", cnt);
  }
  return 0;
}
