One card set is (52 cards) used in clock solitaire. Each card corresponds to one hour. J 2,3,...,10 A Q K one o’clock 2 o’clock, 3 o’clock etc. 11 o’clock 12 o’clock centre of the clock board We give out cards placing (covers up) 4 cards per each hour and centre of clock board. The aim if the game is to uncover all the cards and rearranging them so that each card lies on its corresponding hour. The first move is to uncover the lowest card from the centre. Holding one card in hand we can make only one sort of movement — place the card on its corresponding hour (or in the centre if it is a king) and take the lowest card from its heap. We iterate this procedure as long as possible. The game is successful if you manage to uncover all the cards and — consequently — lost if even single card remains uncovered. Widely known International Association of Solitaire Fans was curious which card sequence produces best results (meaning highest number of successful games). You are to help them by writing a program which reads the initial cards layout and checks how many of 52 cyclic shifts of this string are successful. Input Each input file contains a few sequences of 52 cards separated by end line marks. We give out cards clockwise, starting from the lowest on the first hour and finishing with the uppermost in the center. End if file is marked by a line contains ‘0’. Output For each card sequence print one line with the number of successful games among 52 its cyclic shifts. Sample Input 7J93JQKA23456789T8QKA23456789TJQKA23456789TJQKA2T456 0 Sample Output 4