// Arup Guha
// 11/3/2011
// Solution to 2011 South East Regional Problem A: Sunday Drive
import java.util.*;

public class a {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);

		int N, M;
		N = stdin.nextInt();
		M = stdin.nextInt();

		while (N != 0 || M != 0) {

			// Init distance array with larger values than possible.
			double[][] bestvals = new double[N][M];
			for (int i=0; i<N; i++)
				for (int j=0; j<M; j++)
					bestvals[i][j] = 1000000000;

			// Fill in best distances for segment i.
			// We are running the outer level of our DP from here.
			String prev=null;
			for (int i=0; i<N; i++) {

				String seg = stdin.next();
				if (!seg.equals("S")) {
					if (prev == null)
						prev = seg;
				}

				double length = stdin.nextInt();
				update(bestvals, i, prev, seg, length);

				if (!seg.equals("S")) {
						prev = seg;
				}
			}

			// Find the best of answer for all different lanes and choose the best of these.
			double ans = bestvals[N-1][0];
			for (int j=1; j<M; j++)
				if (bestvals[N-1][j] < ans)
					ans = bestvals[N-1][j];

			System.out.printf("%.2f\n",ans);

			N = stdin.nextInt();
			M = stdin.nextInt();
		}
	}

	// This runs our DP inside the array bestvals.
	public static void update(double[][] bestvals, int segnum, String first, String seg, double length) {

		// Straight segment
		if (seg.equals("S")) {

			// Calculate all possible lane crossovers and pick the best for each.
			int len = bestvals[segnum].length;
			for (int start=0; start<len; start++) {
				for (int j=0; j<len; j++) {

					double prev = 0;
					if (segnum > 0)
						prev = bestvals[segnum-1][start];

					int numlanes = Math.abs(start - j);
					double lanediff = numlanes*10;
					double seglen = Math.sqrt(length*length + lanediff*lanediff);

					// Only do the update if we can change this many lanes.
					if (length >= numlanes*100) {
						bestvals[segnum][j] = Math.min(bestvals[segnum][j], prev + seglen);
					}

				}
			}

		}
		
		// Figure out the curve - this is for one direction.
		else if (seg.equals(first)) {

			for (int j=0; j<bestvals[segnum].length; j++) {
				double prev = 0;
				if (segnum > 0)
					prev = bestvals[segnum-1][j];
				bestvals[segnum][j] = prev + Math.PI*(length+j*10+5)/2;
			}
		}
		
		// This is for the other direction, since the lanes "switch" numbers, so to speak.
		else {
			int len = bestvals[segnum].length;
			for (int j=0; j<bestvals[segnum].length; j++) {
				double prev = 0;
				if (segnum > 0)
					prev = bestvals[segnum-1][len-1-j];
				bestvals[segnum][j] = prev + Math.PI*(length+j*10+5)/2;
			}
		}
	}
}