#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<iomanip>
#include <string>
using namespace std;
int main() {
int n;
string s;
cin >> n >> s;
int gb = s.find("GB");
int mb = s.find("MB");
int kb = s.find("KB");
int gb1 = s.find("GB",1);
int mb1 = s.find("MB",1);
int kb1 = s.find("KB",1);
long double m = n;
cout << fixed << setprecision(6);
if (gb == 0)
{
if (gb1 > 0)cout << m;
else if (mb1 > 0) cout << m * 1024;
else if (kb1 > 0) cout << m * 1024 * 1024;
else cout << m * 1024 * 1024 * 1024;
}
else if (mb == 0)
{
if (gb1 > 0)cout << m/1024;
if (mb1 > 0) cout << m;
else if (kb1 > 0) cout << m * 1024;
else cout << m * 1024 * 1024;
}
else if (kb == 0)
{
if (gb1 > 0)cout << m /1024/1024;
else if (mb1 > 0) cout << m/1024;
else if (kb1 > 0) cout << m;
else cout << m * 1024;
}
else
{
if (gb1 > 0)cout << m / 1024/1024/1024;
else if (mb1 > 0) cout << m / 1024/1024;
else if (kb1 > 0) cout << m/1024;
else cout << m;
}
return 0;
}