#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
inline int read() {
  int res, ok = 1;
  char ch;
  for (ch = getchar(); ch < '0' || ch > '9'; ch = getchar())
    if (ch == '-') ok = -1;
  res = ch - '0';
  for (ch = getchar(); ch >= '0' && ch <= '9'; ch = getchar())
    res = res * 10 + ch - '0';
  return res * ok;
}
int n;
char c[1005];
int d[1005], x[2005], y[2005], xtot, ytot, vis[2005][2005], qx[4000005],
    qy[4000005], p, q;
long long work(int cx, int cy) {
  long long ans = 0;
  p = q = 0;
  qx[q] = cx;
  qy[q++] = cy;
  vis[cx][cy] = 2;
  while (p != q) {
    int nx = qx[p], ny = qy[p];
    p++;
    ans += (long long)(x[nx + 1] - x[nx]) * (y[ny + 1] - y[ny]);
    if (nx + 1 < xtot && !vis[nx + 1][ny]) {
      qx[q] = nx + 1;
      qy[q++] = ny;
      vis[nx + 1][ny] = 2;
    }
    if (nx - 1 >= 1 && !vis[nx - 1][ny]) {
      qx[q] = nx - 1;
      qy[q++] = ny;
      vis[nx - 1][ny] = 2;
    }
    if (ny + 1 < ytot && !vis[nx][ny + 1]) {
      qx[q] = nx;
      qy[q++] = ny + 1;
      vis[nx][ny + 1] = 2;
    }
    if (ny - 1 >= 1 && !vis[nx][ny - 1]) {
      qx[q] = nx;
      qy[q++] = ny - 1;
      vis[nx][ny - 1] = 2;
    }
  }
  return ans;
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) {
    char now;
    for (now = getchar(); now < 'A' || now > 'Z'; now = getchar())
      ;
    c[i] = now;
    d[i] = read();
  }
  int xx = 0, yy = 0, cx, cy;
  x[++xtot] = 0;
  x[++xtot] = 1;
  y[++ytot] = 0;
  y[++ytot] = 1;
  for (int i = 1; i <= n; i++) {
    if (c[i] == 'U') yy += d[i];
    if (c[i] == 'D') yy -= d[i];
    if (c[i] == 'L') xx -= d[i];
    if (c[i] == 'R') xx += d[i];
    x[++xtot] = xx;
    x[++xtot] = xx + 1;
    y[++ytot] = yy;
    y[++ytot] = yy + 1;
  }
  sort(x + 1, x + 1 + xtot);
  xtot = unique(x + 1, x + 1 + xtot) - x - 1;
  sort(y + 1, y + 1 + ytot);
  ytot = unique(y + 1, y + 1 + ytot) - y - 1;
  xx = yy = 0;
  cx = lower_bound(x + 1, x + 1 + xtot, 0) - x;
  cy = lower_bound(y + 1, y + 1 + ytot, 0) - y;
  vis[cx][cy] = 1;
  for (int i = 1; i <= n; i++) {
    if (c[i] == 'U') {
      yy += d[i];
      for (; vis[cx][cy] = 1, y[cy] != yy; cy++)
        ;
    }
    if (c[i] == 'D') {
      yy -= d[i];
      for (; vis[cx][cy] = 1, y[cy] != yy; cy--)
        ;
    }
    if (c[i] == 'L') {
      xx -= d[i];
      for (; vis[cx][cy] = 1, x[cx] != xx; cx--)
        ;
    }
    if (c[i] == 'R') {
      xx += d[i];
      for (; vis[cx][cy] = 1, x[cx] != xx; cx++)
        ;
    }
  }
  long long ans = (long long)(x[xtot] - x[1]) * (y[ytot] - y[1]);
  for (int i = 1; i < xtot; i++) {
    if (!vis[i][1]) ans -= work(i, 1);
    if (!vis[i][ytot - 1]) ans -= work(i, ytot - 1);
  }
  for (int j = 1; j < ytot; j++) {
    if (!vis[1][j]) ans -= work(1, j);
    if (!vis[xtot - 1][j]) ans -= work(xtot - 1, j);
  }
  printf("%I64d\n", ans);
  return 0;
}
