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