#include <iostream>
#include <cstring>
#include <algorithm>
#include <unordered_map>
#define x first
#define y second
using namespace std;
typedef pair<int, int> PII;
PII p[4] = {{0, 1}, {1, 1}, {0, 0}, {1, 0}};
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
unordered_map<string, int> id = {{"FL", 0}, {"FR", 1}, {"RL", 2}, {"RR", 3}};
unordered_map<char, int> turn = {{'F', 0}, {'B', 2}, {'L', 3}, {'R', 1}};
void rotate(PII& a, PII& b)
{
b.x -= a.x, b.y -= a.y;
int x = b.y, y = -b.x;
b.x = a.x + x, b.y = a.y + y;
}
int main()
{
int n;
cin >> n;
int minx = 0, maxx = 1, miny = 0, maxy = 1;
int d = 0;
while (n -- )
{
string str;
cin >> str;
int k = id[str.substr(0, 2)];
char c = str[2];
if (c != 'P')
{
int t = (d + turn[c]) % 4;
p[k].x += dx[t], p[k].y += dy[t];
}
else
{
for (int i = 0; i < 4; i ++ )
if (i != k)
rotate(p[k], p[i]);
d = (d + 1) % 4;
}
for (int i = 0; i < 4; i ++ )
for (int j = 0; j < i; j ++ )
if (p[i] == p[j])
{
puts("-1");
return 0;
}
for (int i = 0; i < 4; i ++ )
{
minx = min(minx, p[i].x);
miny = min(miny, p[i].y);
maxx = max(maxx, p[i].x);
maxy = max(maxy, p[i].y);
}
}
cout << (maxx - minx + 1) * (maxy - miny + 1) << endl;
return 0;
}