#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
int N;
char x;
cin >> N >> x;
double M[12][12] = {0};
double n;
for(int i = 0;i < 12; i ++)
{
for (int j = 0;j < 12; j ++)
{
cin >> n;
M[i][j] = n;
}
}
double sum = 0;
for(int j = 0;j < 12; j ++) sum += M[N][j];
if(x=='S') printf("%.1lf",sum);
else if(x=='M') printf("%.1lf",sum/12);
return 0;
}