WA #6 ???
n=int(input())
s1=['Alice','Ariel','Aurora','Phil','Peter','Olaf','Phoebus','Ralph','Robin' ]
s2=['Bambi','Belle', 'Bolt','Mulan','Mowgli','Mickey','Silver','Simba','Stitch']
s3=['Dumbo','Genie','Jiminy','Kuzko','Kida','Kenai','Tarzan','Tiana','Winnie']
a=s1
k=0
for i in range(n):
s=input()
if s in s1:
if a==s1:
continue
elif a==s2:
k+=1
a=s1
elif a==s3:
k+=2
a=s1
elif s in s2:
if a==s1:
k+=1
a=s2
elif a==s2:
continue
elif a==s3:
k+=1
a=s2
elif s in s3:
if a==s1:
k+=2
a=s3
elif a==s2:
k+=1
a=s2
elif a==s3:
continue
print(k)