#include <bits/stdc++.h>
using namespace std;
const int MAX = 4000 + 10;
const long long LEN = 10000000001LL;
pair<int, int> Go(char dir) {
  if (dir == 'R') return make_pair(0, 1);
  if (dir == 'L') return make_pair(0, -1);
  if (dir == 'U') return make_pair(1, 0);
  if (dir == 'D') return make_pair(-1, 0);
  return make_pair(0, 0);
}
int walk[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
int n, len[MAX], r, c;
char Dir[MAX], Q[3];
set<long long> X, Y;
map<long long, long long> px, py;
long long lx[MAX], ly[MAX];
int g[MAX][MAX];
queue<pair<int, int> > q;
int main() {
  scanf("%d", &n);
  int i, j;
  long long nowx = LEN / 2 + 1, nowy = LEN / 2 + 1;
  X.insert(nowx);
  Y.insert(nowy);
  X.insert(nowx - 1);
  Y.insert(nowy - 1);
  X.insert(nowx + 1);
  Y.insert(nowy + 1);
  X.insert(1), Y.insert(1);
  X.insert(LEN), Y.insert(LEN);
  for (i = 1; i <= n; ++i) {
    scanf("%s%d", Q, &len[i]);
    pair<int, int> go = Go(Dir[i] = Q[0]);
    nowx += go.first * len[i];
    nowy += go.second * len[i];
    X.insert(nowx);
    Y.insert(nowy);
    if (nowx - 1 > 0) X.insert(nowx - 1);
    if (nowx + 1 <= LEN) X.insert(nowx + 1);
    if (nowy - 1 > 0) Y.insert(nowy - 1);
    if (nowy + 1 <= LEN) Y.insert(nowy + 1);
  }
  set<long long>::iterator it;
  for (it = X.begin(); it != X.end(); ++it) lx[px[*it] = ++r] = *it;
  for (it = Y.begin(); it != Y.end(); ++it) ly[py[*it] = ++c] = *it;
  nowx = LEN / 2 + 1, nowy = LEN / 2 + 1;
  int nx = px[nowx], ny = py[nowy];
  g[nx][ny] = 1;
  for (i = 1; i <= n; ++i) {
    pair<int, int> go = Go(Dir[i]);
    nowx += go.first * len[i];
    nowy += go.second * len[i];
    while (lx[nx] != nowx || ly[ny] != nowy) {
      nx += go.first, ny += go.second;
      g[nx][ny] = 1;
    }
  }
  for (i = 1; i <= r; ++i) {
    if (g[i][1] == 0) q.push(make_pair(i, 1)), g[i][1] = -1;
    if (g[i][c] == 0) q.push(make_pair(i, c)), g[i][c] = -1;
  }
  for (i = 1; i <= c; ++i) {
    if (!g[1][i] == 0) q.push(make_pair(1, i)), g[1][i] = -1;
    if (!g[r][i] == 0) q.push(make_pair(r, i)), g[r][i] = -1;
  }
  while (!q.empty()) {
    pair<int, int> now = q.front();
    q.pop();
    for (i = 0; i < 4; ++i) {
      pair<int, int> np =
          make_pair(now.first + walk[i][0], now.second + walk[i][1]);
      if (g[np.first][np.second] == 0 && np.first <= r && np.first >= 1 &&
          np.second <= c && np.second >= 1) {
        g[np.first][np.second] = -1;
        q.push(np);
      }
    }
  }
  long long ans = 0;
  for (i = 1; i <= r; ++i)
    for (j = 1; j <= c; ++j)
      if (g[i][j] != -1) {
        long long nx = (i == r ? LEN + 1 : lx[i + 1]);
        long long ny = (j == c ? LEN + 1 : ly[j + 1]);
        ans += (nx - lx[i]) * (ny - ly[j]);
      }
  cout << ans << endl;
  return 0;
}
