#include <bits/stdc++.h>
using namespace std;
const int nmax = 2000, oo = 2000000000;
const int st[4][4] = {{0, 1}, {1, 0}, {-1, 0}, {0, -1}};
int x[nmax + 18], y[nmax + 18], idx[nmax + 18], idy[nmax + 18], fxl[nmax + 18],
    fxr[nmax + 18], fyl[nmax + 18], fyr[nmax + 18];
int p[nmax + 18], wdx, wdy;
bool ed[nmax + 18][nmax + 18], can[nmax + 18][nmax + 18];
int n;
int q[nmax * nmax + 18][2], qt, qh;
char com[nmax + 18][10];
long long ans;
void downdate(int &a, int b) {
  if (a > b) a = b;
}
int min(int a, int b) { return a > b ? a : b; }
int gcd(int a, int b) { return !b ? a : gcd(b, a % b); }
void decra(int *a, int *ida, int *fal, int *far, int &tot) {
  tot = 1;
  fal[1] = a[p[0]], far[1] = a[p[0]];
  for (int i = 1; i <= n; ++i)
    if (a[p[i]] > a[p[i - 1]]) {
      if (a[p[i]] - 1 > a[p[i - 1]])
        fal[++tot] = a[p[i - 1]] + 1, far[tot] = a[p[i]] - 1;
      fal[++tot] = a[p[i]], far[tot] = a[p[i]];
      ida[p[i]] = tot;
    } else
      ida[p[i]] = tot;
}
bool cmporx(int i, int j) { return x[i] < x[j]; }
bool cmpory(int i, int j) { return y[i] < y[j]; }
int main() {
  scanf("%d", &n);
  int nx = 0, ny = 0;
  for (int i = 1; i <= n; ++i) {
    int dx;
    scanf("%s%d", com[i], &dx);
    if (com[i][0] == 'L') nx -= dx;
    if (com[i][0] == 'R') nx += dx;
    if (com[i][0] == 'U') ny += dx;
    if (com[i][0] == 'D') ny -= dx;
    x[i] = nx, y[i] = ny;
  }
  x[++n] = oo, y[n] = oo;
  x[++n] = -oo, y[n] = -oo;
  for (int i = 0; i <= n; ++i) p[i] = i;
  sort(p, p + n + 1, cmporx);
  decra(x, idx, fxl, fxr, wdx);
  for (int i = 0; i <= n; ++i) p[i] = i;
  sort(p, p + n + 1, cmpory);
  decra(y, idy, fyl, fyr, wdy);
  nx = idx[0], ny = idy[0];
  for (int i = 1; i <= n - 2; ++i) {
    int dx = 0, dy = 0;
    if (com[i][0] == 'L') dx = -1;
    if (com[i][0] == 'R') dx = 1;
    if (com[i][0] == 'U') dy = 1;
    if (com[i][0] == 'D') dy = -1;
    for (; nx != idx[i] || ny != idy[i]; nx += dx, ny += dy) can[nx][ny] = 1;
    can[nx][ny] = 1;
  }
  q[qh = qt = 1][0] = wdx, q[1][1] = wdy;
  ed[wdx][wdy] = 1;
  for (int nx, ny, tx, ty; qh <= qt;) {
    nx = q[qh][0];
    ny = q[qh][1];
    ++qh;
    for (int i = 0; i < 4; ++i) {
      tx = nx + st[i][0], ty = ny + st[i][1];
      if (!(tx > 0 && tx <= wdx && ty > 0 && ty <= wdy)) continue;
      if (ed[tx][ty] || (can[tx][ty])) continue;
      ed[tx][ty] = 1;
      q[++qt][0] = tx, q[qt][1] = ty;
    }
  }
  for (int i = 1; i <= wdx; ++i)
    for (int j = 1; j <= wdy; ++j)
      if (!ed[i][j]) {
        int h = fxl[i] <= fxr[i] ? (fxr[i] - fxl[i] + 1) : 0;
        int w = fyl[j] <= fyr[j] ? (fyr[j] - fyl[j] + 1) : 0;
        ans += (long long)h * w;
      }
  cout << ans << endl;
  return 0;
}
