#include <bits/stdc++.h>
using namespace std;
const int inf = ~0U >> 1;
const long long INF = ~0ULL >> 1;
template <class T>
inline void read(T &n) {
  char c;
  for (c = getchar(); !(c >= '0' && c <= '9'); c = getchar())
    ;
  n = c - '0';
  for (c = getchar(); c >= '0' && c <= '9'; c = getchar()) n = n * 10 + c - '0';
}
int Pow(int base, int n, int mo) {
  if (n == 0) return 1;
  if (n == 1) return base % mo;
  int tmp = Pow(base, n >> 1, mo);
  tmp = (long long)tmp * tmp % mo;
  if (n & 1) tmp = (long long)tmp * base % mo;
  return tmp;
}
const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
int n, cntx, cnty, dir[2000], step[2000], v[2500][2500], vis[2500][2500],
    invalid[2500][2500];
long long ans, hx[3000], hy[3000];
queue<pair<int, int> > Q;
void add(long long x, long long y) {
  hx[++cntx] = x;
  hy[++cnty] = y;
}
int main() {
  scanf("%d", &n);
  long long x = (10000000001ll + 1) / 2;
  long long y = x;
  add(x, y);
  for (int i = (1); i <= (n); ++i) {
    char buf[5];
    scanf("%s", buf);
    if (buf[0] == 'L')
      dir[i] = 0;
    else if (buf[0] == 'R')
      dir[i] = 1;
    else if (buf[0] == 'U')
      dir[i] = 2;
    else
      dir[i] = 3;
    scanf("%d", &step[i]);
    x += step[i] * dx[dir[i]];
    y += step[i] * dy[dir[i]];
    add(x, y);
  }
  sort(hx + 1, hx + cntx + 1);
  sort(hy + 1, hy + cnty + 1);
  cntx = unique(hx + 1, hx + cntx + 1) - hx - 1;
  cnty = unique(hy + 1, hy + cnty + 1) - hy - 1;
  x = (10000000001ll + 1) / 2;
  y = x;
  int curx = lower_bound(hx + 1, hx + cntx + 1, x) - hx;
  int cury = lower_bound(hy + 1, hy + cnty + 1, y) - hy;
  v[curx * 2 - 1][cury * 2 - 1] = 1;
  for (int i = (1); i <= (n); ++i) {
    x += step[i] * dx[dir[i]];
    y += step[i] * dy[dir[i]];
    while (hx[curx] != x || hy[cury] != y) {
      if (dir[i] == 0 && hx[curx] - hx[curx - 1] > 1)
        v[(curx - 1) * 2][cury * 2 - 1] = 1;
      else if (dir[i] == 1 && hx[curx + 1] - hx[curx] > 1)
        v[curx * 2][cury * 2 - 1] = 1;
      else if (dir[i] == 2 && hy[cury] - hy[cury - 1] > 1)
        v[curx * 2 - 1][(cury - 1) * 2] = 1;
      else if (dir[i] == 3 && hy[cury + 1] - hy[cury] > 1)
        v[curx * 2 - 1][cury * 2] = 1;
      curx += dx[dir[i]];
      cury += dy[dir[i]];
      v[curx * 2 - 1][cury * 2 - 1] = 1;
    }
  }
  for (int i = (1); i <= (cntx - 1); ++i)
    if (hx[i + 1] - hx[i] <= 1) {
      for (int j = (1); j <= (2 * cnty); ++j) invalid[i * 2][j] = 1;
    }
  for (int i = (1); i <= (cnty - 1); ++i)
    if (hy[i + 1] - hy[i] <= 1) {
      for (int j = (1); j <= (2 * cntx); ++j) invalid[j][i * 2] = 1;
    }
  vis[0][0] = 1;
  Q.push((make_pair(0, 0)));
  while (Q.size()) {
    pair<int, int> u = Q.front();
    Q.pop();
    if (invalid[u.first][u.second]) continue;
    for (int k = (0); k <= (3); ++k) {
      int nx = u.first + dx[k];
      int ny = u.second + dy[k];
      if (!(nx <= 2 * cntx && ny <= 2 * cnty && nx >= 0 && ny >= 0)) continue;
      if (invalid[nx][ny]) nx += dx[k], ny += dy[k];
      if (nx <= 2 * cntx && ny <= 2 * cnty && nx >= 0 && ny >= 0 &&
          !vis[nx][ny] && !v[nx][ny]) {
        vis[nx][ny] = 1;
        Q.push((make_pair(nx, ny)));
      }
    }
  }
  for (int i = (1); i <= (cntx); ++i)
    for (int j = (1); j <= (cnty); ++j) {
      if (!vis[i * 2 - 1][j * 2 - 1]) ans++;
      if (!vis[i * 2 - 1][j * 2] && j < cnty && !invalid[i * 2 - 1][j * 2])
        ans += hy[j + 1] - hy[j] - 1;
      if (!vis[i * 2][j * 2 - 1] && i < cntx && !invalid[i * 2][j * 2 - 1])
        ans += hx[i + 1] - hx[i] - 1;
      if (!vis[i * 2][j * 2] && i < cntx && j < cnty && !invalid[i * 2][j * 2])
        ans += (hy[j + 1] - hy[j] - 1) * (hx[i + 1] - hx[i] - 1);
    }
  printf("%lld\n", ans);
  return 0;
}
