#include <iostream>
using namespace std;
int main(){
int C;
double num,sum = 0;
char oper;
cin >> C >> oper;
for (int i = 0 ;i < 12;i++){
for (int j = 0;j < 12; j++){
cin >> num;
if (j == C) sum += num;
}
}
printf("%.1lf",oper == 'S'? sum:sum/12);
return 0;
}