// Arup Guha
// 3/23/2015
// Solution to January 14 Bronze USACO Problem: Bessie Slows Down

import java.util.*;
import java.io.*;

public class slowdown {

	final public static double EPSILON = 1e-9;
	final public static int END = 1000;

	public static void main(String[] args) throws Exception {

		// Read in cow values.
		Scanner stdin = new Scanner(new File("slowdown.in"));
		int n = stdin.nextInt();

		PriorityQueue<Integer> tEvents = new PriorityQueue<Integer>();
		PriorityQueue<Integer> dEvents = new PriorityQueue<Integer>();

		// Read in each event into the appropriate priority queue.
		for (int i=0; i<n; i++) {
			String event = stdin.next();
			int value = stdin.nextInt();
			if (event.equals("T"))
				tEvents.offer(value);
			else
				dEvents.offer(value);
		}
		stdin.close();

		// These make sure the queue is never empty!
		tEvents.offer(END*(n+1));
		dEvents.offer(END+1);

		// Round answer...
		int result = (int)(solve(tEvents, dEvents) + 0.5 + EPSILON);

		// Write out the result.
		BufferedWriter fout = new BufferedWriter(new FileWriter("slowdown.out"));
		fout.write(result+"\n");
		fout.close();
	}

	public static double solve(PriorityQueue<Integer> tEvents, PriorityQueue<Integer> dEvents) {

		double curDist = 0, curTime = 0;
		int curDen = 1;
		int result = -1;

		// This is as far as we have to go.
		while (curDist < END) {

			// No more events to occur before we get past the next switch point.
			if (curDist + (tEvents.peek()-curTime)/curDen >= END && dEvents.peek() >= END)
				return curTime + (END-curDist)*curDen;

			// Something MUST occur before the end...
			else {

				// Get distances till next event.
				int nextD = dEvents.peek();
				int nextT = tEvents.peek();
				double dTimeEvent = curDist + ((nextT-curTime)/curDen);


				// Go to the distance event first.
				if (nextD < dTimeEvent) {
					dEvents.poll();
					curTime += ((nextD - curDist)*curDen);
					curDist = nextD;
				}

				// Go to the time event first.
				else {
					tEvents.poll();
					curDist += ((nextT - curTime)/curDen);
					curTime = nextT;
				}

				// We slow down!
				curDen++;
			}
		}

		// Should never get here...
		return END;
	}
}
