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