x = int(input())
s = input()
m = 0
k = 0
for i in range(x):
    if s[i] != "F":
        if not "I" in s[0:i] + s[i+2:]:
            k = s.count('A')
            if k > m:
                m = k
            k = 0

print(m)
