import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Solution to
 * 
 * @author vanb
 */
public class moonlit_vanb
{
    /** Input. */
    private static Scanner sc;
    
    /** Output. */
    private static PrintStream ps;
    
    /**
     * Do it!
     */
    private void doit()
    {
        String phases[] = new String[28];
        phases[0] = "New";
        for( int i=1; i<=4; i++ ) phases[i] = "Crescent";
        for( int i=5; i<=8; i++ ) phases[i] = "Quarter";
        for( int i=9; i<=13; i++ ) phases[i] = "Gibbous";
        phases[14] = "Full";
        for( int i=15; i<=19; i++ ) phases[i] = "Gibbous";
        for( int i=20; i<=22; i++ ) phases[i] = "Quarter";
        for( int i=23; i<=27; i++ ) phases[i] = "Crescent";
        
        int n = sc.nextInt();
        String observations[] = new String[n]; 
        for( int i=0; i<n; i++ ) observations[i] = sc.next();
        
        boolean found = false;
        int answer = -1;
        for( int step=1; step<=28 && !found; step++ )
        {
            int day = 0;
            found = true;
            for( int i=0; i<n && found; i++ )
            {
                day += step;
                day %= 28;
                if( !observations[i].equals( phases[day] ) ) found = false;
            }
            if( found ) answer = step;
        }
        
        ps.println( answer );
    }
        
    /**
     * Main.
     * 
     * @param args unused
     * @throws Exception
     */
    public static void main( String[] args ) throws Exception
    {
        sc = new Scanner( System.in );
        ps = System.out;
        
        new moonlit_vanb().doit();
    }

}
