#!/usr/bin/python

try:
    while True:
        N_, T = input().split(' ')
        N = int(N_)
        if T == 'K':
            print(1 if N == 1 else 4)
        elif T == 'N':
            print(1 if N <= 2 else 2)
        else:
            print(N)
        
except EOFError:
    pass
