#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 5;
int read(int x = 0, int f = 1, char c = getchar()) {
  for (; c < '0' || c > '9'; c = getchar())
    if (c == '-') f = -1;
  for (; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - '0';
  return x * f;
}
struct Node {
  int lx, ly, rx, ry;
} a[N];
long long ans;
bool v[N * 3][N * 3];
int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
int n, bx[N * 3], by[N * 3], mx, my, qx[N * N * 9], qy[N * N * 9];
void Add(int x, int y) {
  bx[++mx] = x - 1;
  bx[++mx] = x;
  bx[++mx] = x + 1;
  by[++my] = y - 1;
  by[++my] = y;
  by[++my] = y + 1;
}
int main() {
  n = read();
  bx[++mx] = -1e9 - 1;
  bx[++mx] = 1e9 + 1;
  bx[++mx] = 1e9 + 2;
  by[++my] = -1e9 - 1;
  by[++my] = 1e9 + 1;
  by[++my] = 1e9 + 2;
  int x = 0, y = 0;
  Add(0, 0);
  for (int i = 1; i <= n; ++i) {
    char od;
    scanf(" %c", &od);
    int l = read();
    a[i].lx = x, a[i].ly = y;
    od == 'U' ? x -= l : od == 'D' ? x += l : od == 'L' ? y -= l : y += l;
    a[i].rx = x, a[i].ry = y;
    Add(x, y);
  }
  sort(bx + 1, bx + mx + 1);
  sort(by + 1, by + my + 1);
  mx = unique(bx + 1, bx + mx + 1) - bx - 1;
  my = unique(by + 1, by + my + 1) - by - 1;
  for (int k = 1; k <= n; ++k) {
    int lx = lower_bound(bx + 1, bx + mx + 1, a[k].lx) - bx;
    int ly = lower_bound(by + 1, by + my + 1, a[k].ly) - by;
    int rx = lower_bound(bx + 1, bx + mx + 1, a[k].rx) - bx;
    int ry = lower_bound(by + 1, by + my + 1, a[k].ry) - by;
    if (lx > rx || ly > ry) swap(lx, rx), swap(ly, ry);
    for (int i = lx; i <= rx; ++i)
      for (int j = ly; j <= ry; ++j) v[i][j] = 1;
  }
  int l = 1, r = 1;
  qx[1] = qy[1] = 1;
  v[1][1] = 1;
  ans = 1ll * ((int)2e9 + 3) * ((int)2e9 + 3);
  while (l <= r) {
    int x = qx[l], y = qy[l];
    l++;
    ans -= 1ll * (bx[x + 1] - bx[x]) * (by[y + 1] - by[y]);
    for (int k = 0; k < 4; ++k) {
      int tx = x + dx[k], ty = y + dy[k];
      if (tx <= 0 || tx >= mx || ty <= 0 || ty >= my || v[tx][ty]) continue;
      r++;
      qx[r] = tx;
      qy[r] = ty;
      v[tx][ty] = 1;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
