#include <bits/stdc++.h>
const double eps = 1e-9;
const double pi = acos(-1);
const int oo = 1000000000;
const int mod = 1000000009;
const double E = 2.7182818284590452353602874713527;
using namespace std;
struct case1 {
  bool flag;
  int x, y1, y2;
} rec[3001];
bool mark[3005][3005];
int rx[3005], ry[3005], l[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
int ox = 1, oy = 1;
long long ans = 2000000010LL * 2000000010LL;
void dfs(int x, int y) {
  mark[x][y] = 1;
  ans -= 1LL * (rx[x + 1] - rx[x]) * (ry[y + 1] - ry[y]);
  for (int i = 0; i < 4; i++) {
    int xx = x + l[i][0], yy = y + l[i][1];
    if (xx && yy && xx < ox && yy < oy && !mark[xx][yy]) dfs(xx, yy);
  }
}
int main() {
  int n, o = 0, x = 1000000005, y = 1000000005;
  cin >> n;
  rx[++ox] = 2000000010;
  ry[++oy] = 2000000010;
  for (int i = 1; i <= n; i++) {
    char c, t[5];
    int l;
    scanf("%s%d", t, &l);
    c = t[0];
    if (c == 'L') {
      rec[++o] = (case1){0, y, x - l, x + 1};
      rx[++ox] = x - l;
      rx[++ox] = x + 1;
      ry[++oy] = y;
      ry[++oy] = y + 1;
      x -= l;
    } else if (c == 'R') {
      rec[++o] = (case1){0, y, x, x + l + 1};
      rx[++ox] = x + l + 1;
      rx[++ox] = x;
      ry[++oy] = y;
      ry[++oy] = y + 1;
      x += l;
    } else if (c == 'D') {
      rec[++o] = (case1){1, x, y - l, y + 1};
      rx[++ox] = x;
      rx[++ox] = x + 1;
      ry[++oy] = y - l;
      ry[++oy] = y + 1;
      y -= l;
    } else {
      rec[++o] = (case1){1, x, y, y + l + 1};
      rx[++ox] = x;
      rx[++ox] = x + 1;
      ry[++oy] = y + l + 1;
      ry[++oy] = y;
      y += l;
    }
  }
  sort(rx + 1, rx + ox + 1);
  ox = unique(rx + 1, rx + ox + 1) - rx - 1;
  sort(ry + 1, ry + oy + 1);
  oy = unique(ry + 1, ry + oy + 1) - ry - 1;
  for (int i = 1; i <= o; i++)
    if (rec[i].flag == 0) {
      int y;
      for (y = 1; ry[y] < rec[i].x; y++)
        ;
      for (int j = 1; j < ox; j++)
        if (rx[j] >= rec[i].y1 && rx[j + 1] <= rec[i].y2) mark[j][y] = 1;
    } else {
      int x;
      for (x = 1; rx[x] < rec[i].x; x++)
        ;
      for (int j = 1; j < oy; j++)
        if (ry[j] >= rec[i].y1 && ry[j + 1] <= rec[i].y2) mark[x][j] = 1;
    }
  for (int i = 1; i < ox; i++) {
    if (!mark[i][1]) dfs(i, 1);
    if (!mark[i][oy - 1]) dfs(i, oy - 1);
  }
  for (int i = 1; i < oy; i++) {
    if (!mark[1][i]) dfs(1, i);
    if (!mark[ox - 1][i]) dfs(ox - 1, i);
  }
  cout << ans << endl;
  return 0;
}
