#include<iostream>
#include<cstdio>
using namespace std;
int main(){
char ch;
scanf("%c",&ch);
double a,sum=0;
for(int i=0;i<12;i++){
for(int j=0;j<12;j++){
cin>>a;
if(i>j&&i+j<=10) sum+=a;
}
}
if(ch=='S') printf("%.1f\n",sum);
else if(ch=='M') printf("%.1f\n",sum/30);
else cout<<"error"<<endl;
return 0;
}