// Arup Guha
// 11/8/2025
// Solution to 2025 SER D2 Problem M: Moonlit Time Machine.
// Written during contest, commented later.

import java.util.*;

public class moonlittimemachine {

	final public static int[] CODES = {0,1,1,1,1,2,2,2,2,3,3,3,3,3,4,3,3,3,3,3,2,2,2,1,1,1,1,1};
	final public static String[] NAMES = {"New", "Crescent", "Quarter", "Gibbous", "Full"};
	
	public static void main(String[] args) {
	
		// For easy access.
		HashMap<String,Integer> map = new HashMap<String,Integer>();
		for (int i=0; i<NAMES.length; i++)
			map.put(NAMES[i], i);
		
		Scanner stdin = new Scanner(System.in);
		int n = stdin.nextInt();
		
		// Store which phases.
		int[] list = new int[n];
		for (int i=0; i<n; i++) {
			list[i] = map.get(stdin.next());
		}
		
		// Go in order to find the first possible answer.
		int res = -1;
		for (int i=1; i<=28; i++) {
			if (possible(list, i)) {
				res = i;
				break;
			}
		}
		
		System.out.println(res);
	}
	
	// This checks for consistency.
	public static boolean possible(int[] list, int step) {
		
		int n = list.length;
			
		// Assume it works until we find out otherwise.
		boolean tmp = true;
		
		// Just do our step size.
		for (int j=step; j<step+step*n; j+=step) {
				
			// See if this violates one of our observations.
			int curD = j%28;
			int idx = (j-1)/step;
			if (CODES[curD] != list[idx]) {
				tmp = false;
				break;
			}
		}
		
		// This will store the consistency info.
		return tmp;
	}
}