#include <bits/stdc++.h>
using namespace std;
namespace IO {
const int MAXIOSIZE = 1 << 24 | 1;
unsigned char buf[MAXIOSIZE], *p1, *p2;
template <typename T>
void read(T& x) {
  x = 0;
  char ch = getchar();
  bool flg = false;
  for (; ch < '0' || '9' < ch; ch = getchar())
    if (ch == '-') flg |= true;
  for (; '0' <= ch && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
  flg ? x = -x : 0;
}
template <typename T>
void out(const T& x) {
  if (x > 9) out(x / 10);
  putchar(x % 10 + '0');
}
template <typename T>
inline void write(const T& x, const char& ed = ' ') {
  if (x < 0)
    putchar('-'), out(-x);
  else
    out(x);
  putchar(ed);
}
}  // namespace IO
const int MAXN = 1000 + 10;
const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
long long ans, ans2;
int n, cnt, curx, cury;
struct Node {
  int sx, sy, ex, ey;
} t[MAXN];
int _num(char opt) {
  if (opt == 'R') return 0;
  if (opt == 'L') return 1;
  if (opt == 'U') return 2;
  if (opt == 'D') return 3;
}
int tablex[MAXN * 10], tablesizex, tabley[MAXN * 10], tablesizey;
bool mp[MAXN << 2][MAXN << 2], vis[MAXN << 2][MAXN << 2];
void dfs(int u, int v) {
  if (u < 0 || v < 0 || u > tablesizex || v > tablesizey || mp[u][v] ||
      vis[u][v])
    return;
  vis[u][v] = true;
  for (int _ = (0), _end = (3); _ <= _end; ++_) dfs(u + dx[_], v + dy[_]);
}
int main() {
  IO::read(n);
  for (int i = (1), iend = (n); i <= iend; ++i) {
    char opt[10];
    int x;
    scanf("%s", opt + 1), IO::read(x);
    int nxtx = curx + dx[_num(opt[1])] * x, nxty = cury + dy[_num(opt[1])] * x;
    t[++cnt] = {min(nxtx, curx), min(nxty, cury), max(nxtx, curx) + 1,
                max(nxty, cury) + 1};
    curx = nxtx, cury = nxty;
  }
  for (int i = (1), iend = (cnt); i <= iend; ++i)
    tablex[++tablesizex] = t[i].sx, tabley[++tablesizey] = t[i].sy,
    tablex[++tablesizex] = t[i].ex, tabley[++tablesizey] = t[i].ey;
  sort(tablex + 1, tablex + tablesizex + 1);
  tablesizex = unique(tablex + 1, tablex + tablesizex + 1) - tablex - 1;
  sort(tabley + 1, tabley + tablesizey + 1);
  tablesizey = unique(tabley + 1, tabley + tablesizey + 1) - tabley - 1;
  for (int i = (1), iend = (cnt); i <= iend; ++i) {
    t[i].sx =
        lower_bound(tablex + 1, tablex + tablesizex + 1, t[i].sx) - tablex,
    t[i].sy =
        lower_bound(tabley + 1, tabley + tablesizey + 1, t[i].sy) - tabley,
    t[i].ex =
        lower_bound(tablex + 1, tablex + tablesizex + 1, t[i].ex) - tablex,
    t[i].ey =
        lower_bound(tabley + 1, tabley + tablesizey + 1, t[i].ey) - tabley;
    for (int j = (t[i].sx), jend = (t[i].ex - 1); j <= jend; ++j)
      for (int k = (t[i].sy), kend = (t[i].ey - 1); k <= kend; ++k)
        mp[j][k] = true;
  }
  for (int i = (0), iend = (tablesizex); i <= iend; ++i) {
    for (int j = (0), jend = (tablesizey); j <= jend; ++j) {
      if (i == 0 || j == 0 || i == tablesizex || j == tablesizey) dfs(i, j);
    }
  }
  for (int j = (1), jend = (tablesizey); j <= jend; ++j) {
    for (int i = (1), iend = (tablesizex); i <= iend; ++i) {
      if (!vis[i][j]) {
        ans += 1ll * (tablex[i + 1] - tablex[i]) * (tabley[j + 1] - tabley[j]);
      }
    }
  }
  IO::write(ans, '\n');
  return 0;
}
