# include <bits/stdc++.h>
# define x first
# define y second
using namespace std;
typedef pair<int,int> PII;
unordered_map<string,int> m = {{"FR",0},{"FL",1},{"RR",3},{"RL",2}};
unordered_map<char,int> t = {{'F',0},{'B',1},{'L',2},{'R',3}};
int state[4][4][2] = {{{0,1},{0,-1},{-1,0},{1,0}},
{{1,0},{-1,0},{0,1},{0,-1}},
{{0,-1},{0,1},{1,0},{-1,0}},
{{-1,0},{1,0},{0,-1},{0,1}}};
PII RLRL[4] ={ {1,1},{0,1},{0,0},{1,0}};
int u = 1, d = 0, l = 0, r = 1;
bool judge(){
set<PII>rec;
for(auto &x : RLRL){
if(rec.count(x))return true;
rec.insert(x);
}
return false;
}
void refre(){
for(auto x : RLRL){
u = max(x.y,u);
d = min(x.y,d);
l = min(x.x,l);
r = max(x.x,r);
}
}
void P(int pole){
for(int i = 0; i <= 3; ++i){
if(i == pole)continue;
RLRL[i] = {RLRL[i].y - RLRL[pole].y + RLRL[pole].x,RLRL[pole].x - RLRL[i].x + RLRL[pole].y};
}
}
void forward(int dir, int one,int dir2){
RLRL[one].x += state[dir][dir2][0];
RLRL[one].y += state[dir][dir2][1];
}
int main(){
int dir = 0;
int n;
cin >> n;
string s;
while(n--){
cin >> s;
if(s[2] == 'P'){
P(m[s.substr(0,2)]);
dir = (dir+1) % 4;
refre();
}
else{
forward(dir,m[s.substr(0,2)],t[s[2]]);
refre();
}
if(judge()){
puts("-1");
return 0;}
}
cout << (u - d+1) * (r - l+1) << endl;
return 0;
}