import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

public class CF_174_B_Poker {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        InputStreamReader rd = new InputStreamReader(System.in);
        int n = sc.nextInt();
        sc.nextLine();
        //String s = sc.nextLine();
        int a = 0, i = 0;
        for (int k = 0; k < n; k++){
            char c = 0;
            try {
                c = (char) rd.read();
            } catch (IOException e) {
                e.printStackTrace();
            }
            switch (c) {
                case 'a':
                    a++;
                    break;
                case 'i':
                    i++;
                    break;
            }
        }
        if (i==1)
            System.out.println(1);
        else if (i>1)
            System.out.println(0);
        else 
            System.out.println(a);
        sc.close();
    }

}
