

n = int(input())
s = input().lower()
cnt1 = 0
cnt2 = 0

if len(set(s)) == 1 and s[0] == 'f':
    print(0)
    exit(0)


for i in range(n):
    if s[i] == 'a' and s.count('f') > 0  and s.count('a') > 1 :
        cnt1 +=1

    if s[i] == 'i' and s.count('a') > 0 and s.count('f') > 0 :
        cnt1 +=1


print(cnt1)



