#include <iostream>
#include <string>
using namespace std;
int main ()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    if(n==1)
      cout<<"0";
    if(n==2){
      if(s.rfind("A")==s.find("A"))
           cout<<"1";
      else
           cout<<"0";
    }
    
    return 0;
}