#include <bits/stdc++.h>
using namespace std;
const long long INF = 2e9;
int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while ('0' <= c && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * f;
}
int n, recx[2005], recy[2005];
long long rawx[2005 * 2], rawy[2005 * 2], ans;
map<int, int> refx, refy;
int allx = -1, ally = -1;
int dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};
struct Op {
  char ch;
  long long len;
} op[2005];
int vis[2005 * 2][2005 * 2];
queue<pair<int, int> > Q;
void bfs() {
  Q.push(make_pair(0, 0));
  vis[0][0] = 2;
  while (Q.size()) {
    long long x = Q.front().first, y = Q.front().second;
    Q.pop();
    for (int k = 0; k < 4; ++k) {
      long long tx = x + dx[k], ty = y + dy[k];
      if (tx < 0 || ty < 0 || tx > allx + 1 || ty > ally + 1) continue;
      if (x && x <= allx && y && y <= ally && !(x & 1) &&
          rawx[x - 1] + 1 == rawx[x + 1] && k < 2)
        continue;
      if (x && x <= allx && y && y <= ally && !(y & 1) &&
          rawy[y - 1] + 1 == rawy[y + 1] && k > 1)
        continue;
      if (!vis[tx][ty]) {
        vis[tx][ty] = 2;
        Q.push(make_pair(tx, ty));
      }
    }
  }
  for (int i = 1; i <= allx; ++i)
    for (int j = 1; j <= ally; ++j) {
      if (vis[i][j] == 2) continue;
      if ((i & 1) && (j & 1)) ++ans;
      if ((i & 1) && !(j & 1)) ans += (rawy[j + 1] - rawy[j - 1] - 1);
      if (!(i & 1) && (j & 1)) ans += (rawx[i + 1] - rawx[i - 1] - 1);
      if (!(i & 1) && !(j & 1))
        ans += 1ll * (rawx[i + 1] - rawx[i - 1] - 1) *
               (rawy[j + 1] - rawy[j - 1] - 1);
    }
}
int main() {
  n = read();
  int x = 0, y = 0;
  for (int i = 1; i <= n; ++i) {
    scanf(" %c", &op[i].ch);
    op[i].len = read();
    recx[i] = x, recy[i] = y;
    if (op[i].ch == 'L') x -= op[i].len;
    if (op[i].ch == 'R') x += op[i].len;
    if (op[i].ch == 'D') y -= op[i].len;
    if (op[i].ch == 'U') y += op[i].len;
  }
  recx[n + 1] = x, recy[n + 1] = y;
  sort(recx + 1, recx + n + 2);
  sort(recy + 1, recy + n + 2);
  recx[0] = recy[0] = -INF;
  for (int i = 1; i <= n + 1; ++i)
    if (recx[i] != recx[i - 1])
      allx += 2, refx[recx[i]] = allx, rawx[allx] = recx[i];
  for (int i = 1; i <= n + 1; ++i)
    if (recy[i] != recy[i - 1])
      ally += 2, refy[recy[i]] = ally, rawy[ally] = recy[i];
  x = 0, y = 0;
  for (int i = 1; i <= n; ++i) {
    int X = refx[x], Y = refy[y];
    if (op[i].ch == 'L') {
      int nexX = refx[x - op[i].len];
      for (int j = X; j >= nexX; --j) vis[j][Y] = 1;
      x -= op[i].len;
    }
    if (op[i].ch == 'R') {
      int nexX = refx[x + op[i].len];
      for (int j = X; j <= nexX; ++j) vis[j][Y] = 1;
      x += op[i].len;
    }
    if (op[i].ch == 'D') {
      int nexY = refy[y - op[i].len];
      for (int j = Y; j >= nexY; --j) vis[X][j] = 1;
      y -= op[i].len;
    }
    if (op[i].ch == 'U') {
      int nexY = refy[y + op[i].len];
      for (int j = Y; j <= nexY; ++j) vis[X][j] = 1;
      y += op[i].len;
    }
  }
  bfs();
  cout << ans << endl;
  return 0;
}
