text: Since the information of the foot that Kerr moved by going up and down the platform is given, find the number of times that he went up and down correctly.However, it is assumed that both feet are on the floor before going up and down the platform.Input The input consists of multiple data sets, and the number of data sets contained in one input is 150 or less.The format of each data set is as follows.> $ n $ > $ f_1 $ $ f_2 $ ...$ f_n $ In the first line, the integer $ n $ ($ 1 \ le n \ le 100 $) representing the number of times the foot is moved is given.In the second line, $ f_i $, which is a character string representing the movement of the foot, is given in chronological order by $ n $, separated by spaces.$ f_i $ is one of the following four types of character strings.* "lu": Raise your left foot to the platform.* "ru": Raise your right foot to the platform.* "ld": Lower your left foot to the floor.* "rd": Lower your right foot to the floor.It can be assumed that no action is input that lowers the foot on the floor or raises the foot on the platform.The line where $ n $ is 0 indicates the end of input.Do not process this data.Output For each dataset, output the number of correct steps up and down in one line.Note that if you do not output a line break at the end of each line, or if you output unnecessary characters, it will be judged as an incorrect answer.Sample Input Four lu ru ld rd Four lu ld lu ru 1 lu Ten ru lu ld rd ru rd ru lu lu rd ld 0 Output for Sample Input 2 1 0 Four Example Input 4 lu ru ld rd 4 lu ld lu ru 1 lu 10 ru lu ld rd ru rd ru lu rd ld 0 Output 2 1 0 4 # Solution while 1: n = input() if n == 0: break F = raw_input().split() mode = 1 s = [0,0] ans = 0 for f in F: if f[0]=="l": s[0]^=1 if mode != s[0]: mode = -1 else: s[1]^=1 if mode != s[1]: mode = -1 if s[0]==s[1]: if mode == s[0]: ans += 1 mode = s[0]^1 print ans