


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

if len(set(s)) == 1:
    print(0)
    exit(0)

for i in range(n):
    if s[i] == 'i':
        cnt1 +=1

for i in range(n):
    if s[i] == 'a':
        cnt2 +=1


print(max(cnt2 , cnt1))





