package 每日一题;
import java.util.*;
import javax.xml.crypto.dsig.CanonicalizationMethod;
import java.io.*;
public class Main{
public static void init(HashMap[HTML_REMOVED] map){
map.put(“Ox”, 0);
map.put(“Tiger”, 1);
map.put(“Rabbit”, 2);
map.put(“Dragon”, 3);
map.put(“Snake”, 4);
map.put(“Horse”, 5);//18
map.put(“Goat”, 6);
map.put(“Monkey”, 7);
map.put(“Rooster”, 8);
map.put(“Dog”, 9);
map.put(“Pig”, 10);
map.put(“Rat”, 11);
}
public static void getAns(){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
HashMap<String, Integer> book = new HashMap<>();
HashMap<String, Integer> map = new HashMap<>();
map.put("Bessie", 0);
init(book);
String[] s = new String[8];
while(n-- > 0){
for(int i = 0;i < 8;i++){
s[i] = sc.next();
}
if(s[3].equals("previous")){
int x = map.get(s[7]);
int y = book.get(s[4]);
int r = ((x - y) % 12 + 12 ) %12;
if(r == 0){
r = 12;
}
int ans = x - r;
map.put(s[0], ans);
}else{
int x = map.get(s[7]);
int y = book.get(s[4]);
int r = ((y - x) % 12 + 12 ) %12;
if(r == 0){
r = 12;
}
int ans = x + r;
map.put(s[0], ans);
}
}
System.out.println(Math.abs(map.get("Elsie")));
}
public static void main(String[] args) {
getAns();
}
}