#include <bits/stdc++.h>
using namespace std;
int n;
struct sq {
  int x1, y1, x2, y2;
};
vector<sq> R;
int X, Y;
map<int, int> mx, my;
int xm[2018], ym[2018];
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
bool ziw[2007][2007], lgl[2007][2007];
long long ans;
void dfs(int x, int y) {
  if (x < 0 || x >= X || y < 0 || y >= Y || ziw[x][y] || lgl[x][y]) return;
  lgl[x][y] = 1;
  for (int i = 0; i < 4; i++) dfs(x + dx[i], y + dy[i]);
}
int main() {
  cin >> n;
  int x = 0, y = 0;
  for (int i = 0; i < n; i++) {
    string dir;
    int d;
    cin >> dir >> d;
    if (dir == "L") {
      sq bb = {x - d, y, x + 1, y + 1};
      R.push_back(bb);
      x -= d;
    }
    if (dir == "R") {
      sq bb = {x, y, x + d + 1, y + 1};
      R.push_back(bb);
      x += d;
    }
    if (dir == "U") {
      sq bb = {x, y, x + 1, y + d + 1};
      R.push_back(bb);
      y += d;
    }
    if (dir == "D") {
      sq bb = {x, y - d, x + 1, y + 1};
      R.push_back(bb);
      y -= d;
    }
  }
  for (int i = 0; i < n; i++) {
    mx[R[i].x1] = mx[R[i].x2] = 0;
    my[R[i].y1] = my[R[i].y2] = 0;
  }
  for (__typeof(mx.begin()) it = mx.begin(); it != mx.end(); it++) {
    it->second = X;
    xm[X] = it->first;
    X++;
  }
  X--;
  for (__typeof(my.begin()) it = my.begin(); it != my.end(); it++) {
    it->second = Y;
    ym[Y] = it->first;
    Y++;
  }
  Y--;
  for (int i = 0; i < n; i++) {
    int x1 = mx[R[i].x1], y1 = my[R[i].y1], x2 = mx[R[i].x2], y2 = my[R[i].y2];
    for (int j = x1; j < x2; j++)
      for (int k = y1; k < y2; k++) ziw[j][k] = 1;
  }
  for (int i = 0; i < X; i++)
    for (int j = 0; j < Y; j++)
      if (i == 0 || i == X - 1 || j == 0 || j == Y - 1) dfs(i, j);
  for (int i = 0; i < X; i++)
    for (int j = 0; j < Y; j++)
      if (!lgl[i][j]) {
        long long disx = xm[i + 1] - xm[i], disy = ym[j + 1] - ym[j];
        ans += disx * disy;
      }
  cout << ans << endl;
  return 0;
}
