#include <bits/stdc++.h>
using namespace std;
int vis[2500][2500];
int nm[2500][2500];
char ch[5];
long long ans;
int lenx[2500], leny[2500];
int n, x, y, cnt, dx[205], dy[205];
int cntx, cnty, hx[5005], hy[5005];
struct line {
  int x1, y1, x2, y2;
} l[1005];
int ha(int x, int k) {
  return !k ? lower_bound(hx + 1, hx + 1 + cntx, x) - hx
            : lower_bound(hy + 1, hy + 1 + cnty, x) - hy;
}
void dfs(int i, int j) {
  if (i < 0 || j < 0 || i > cntx + 1 || j > cnty + 1 || vis[i][j] || nm[i][j])
    return;
  vis[i][j] = 1;
  dfs(i + 1, j);
  dfs(i - 1, j);
  dfs(i, j + 1);
  dfs(i, j - 1);
}
int main() {
  scanf("%d", &n);
  hx[++cntx] = x;
  hy[++cnty] = y;
  hx[++cntx] = x + 1;
  hy[++cnty] = y + 1;
  dx['R'] = 1;
  dx['L'] = -1;
  dy['U'] = 1;
  dy['D'] = -1;
  for (int i = 1, len; i <= n; i++) {
    scanf("%s%d", ch + 1, &len);
    l[++cnt] = (line){x, y, x + len * dx[ch[1]], y + len * dy[ch[1]]};
    hx[++cntx] = (x += len * dx[ch[1]]);
    hx[++cntx] = x + 1;
    hy[++cnty] = (y += len * dy[ch[1]]);
    hy[++cnty] = y + 1;
  }
  sort(hx + 1, hx + 1 + cntx);
  cntx = unique(hx + 1, hx + 1 + cntx) - hx - 1;
  sort(hy + 1, hy + 1 + cnty);
  cnty = unique(hy + 1, hy + 1 + cnty) - hy - 1;
  for (int k = 1; k <= cnt; k++) {
    int hx1 = ha(l[k].x1, 0), hy1 = ha(l[k].y1, 1), hx2 = ha(l[k].x2, 0),
        hy2 = ha(l[k].y2, 1);
    if (hx1 == hx2) {
      if (hy1 > hy2) swap(hy1, hy2);
      for (int i = hy1; i <= hy2; nm[hx1][i] = 1, i++)
        ;
    }
    if (hy1 == hy2) {
      if (hx1 > hx2) swap(hx1, hx2);
      for (int i = hx1; i <= hx2; nm[i][hy1] = 1, i++)
        ;
    }
  }
  dfs(0, 0);
  for (int i = 1; i <= cntx; i++)
    for (int j = 1; j <= cnty; j++)
      if (!vis[i][j]) {
        if (i == cntx && j == cnty) ans += 1ll;
        if (i != cntx && j == cnty) ans += 1ll * (hx[i + 1] - hx[i]);
        if (i == cntx && j != cnty) ans += 1ll * (hy[j + 1] - hy[j]);
        if (i != cntx && j != cnty)
          ans += 1ll * (hx[i + 1] - hx[i]) * (hy[j + 1] - hy[j]);
      }
  printf("%lld\n", ans);
}
