import java.io.*;

class Main {
	public static void main(String[] args) {
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			StringBuilder sb = new StringBuilder();
			BaseballRule baseballRule = new BaseballRule();
			Inning inning = new Inning(baseballRule);
			
			int endInning = Integer.parseInt(br.readLine()); //????????????????????¶??¨????????????????????°??°
			int loadedInningNum = 0; //????????????????????????????????????????????°??°

			while (loadedInningNum < endInning){
				int score = loadInnigEvent(br, inning);
				sb.append(score + "\n");
				
				inning.init();
				loadedInningNum++;
			}
			
			System.out.print(sb);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/*
	 * 1???????????°????????§?????\????????????????????????????????????????????????
	 */
	private static int loadInnigEvent(BufferedReader br, Inning inning) throws IOException {
		String loadingEvent;
		while ((loadingEvent = br.readLine()) != null) {
			updateGameField(loadingEvent, inning);
			if(inning.shouldChange()){
				break;
			}
		}
		return inning.getScore();
	}

	/*
	 * ??\????????????????????????????????\????????????????????????????????????????????????????????????????????????
	 */
	private static void updateGameField(String loadingEvent, Inning inning) {
		switch (loadingEvent) {
		case "OUT":
			inning.out();
			break;

		case "HIT":
			inning.hit();
			break;
			
		case "HOMERUN":
			inning.homerun();
			break;
			
		default:
			break;
		}
	}

	
	static class BaseballRule {
		final int COUNT_BASE = 3; //??°????????????????¨??????????????????°????????????????????????
		final int MAX_OUT_PER_INNING = 3; //???????????°????????????????????¶??¨???????????¢??????????????????????????????????????????

		public int getCOUNT_BASE() {
			return COUNT_BASE;
		}

		public int getMAX_OUT_PER_INNING() {
			return MAX_OUT_PER_INNING;
		}
	}
	
	
	static class Inning{
		private int outCount;
		private int score;
		private int personsOnBases;
		private BaseballRule baseballRule;
		
		public Inning(BaseballRule baseballRule){
			this.outCount = 0;
			this.score = 0;
			this.personsOnBases = 0;
			this.baseballRule = baseballRule;
		}
		
		/*
		 * Inning ??????????????????????????????????????????????????????
		 */
		public void init() {
			this.outCount = 0;
			this.score = 0;
			this.personsOnBases = 0;
		}
		
		public void homerun(){
			this.score += this.personsOnBases + 1; //+1 ?????????????????????????????£?????????????????????????????°
			this.personsOnBases = 0;
		}
		
		public void hit(){
			this.personsOnBases++;
			if(baseballRule.getCOUNT_BASE() < this.personsOnBases){
				this.score += 1;
				this.personsOnBases = baseballRule.getCOUNT_BASE();
			}
		}
		
		public void out(){
			this.outCount += 1;
		}
		
		/*
		 * ??¢?????????????????????????????°??\???????????£?????´?????????????????°?????????????????????
		 */
		public boolean shouldChange(){
			if(baseballRule.getMAX_OUT_PER_INNING() <= this.outCount){
				return true;
			}
			return false;
		}
		
		public int getOutCount() {
			return this.outCount;
		}

		public void setOutCount(int outCount) {
			this.outCount = outCount;
		}

		public int getScore() {
			return score;
		}

		public void setScore(int score) {
			this.score = score;
		}
	}
}

Measured memory_bytes: 24112