#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
inline void smin(T &a, U b) {
  if (a > b) a = b;
}
template <typename T, typename U>
inline void smax(T &a, U b) {
  if (a < b) a = b;
}
template <class T>
inline void gn(T &first) {
  char c, sg = 0;
  while (c = getchar(), (c > '9' || c < '0') && c != '-')
    ;
  for ((c == '-' ? sg = 1, c = getchar() : 0), first = 0; c >= '0' && c <= '9';
       c = getchar())
    first = (first << 1) + (first << 3) + c - '0';
  if (sg) first = -first;
}
template <class T, class T1>
inline void gn(T &first, T1 &second) {
  gn(first);
  gn(second);
}
template <class T, class T1, class T2>
inline void gn(T &first, T1 &second, T2 &z) {
  gn(first);
  gn(second);
  gn(z);
}
template <class T>
inline void print(T first) {
  if (first < 0) {
    putchar('-');
    return print(-first);
  }
  if (first < 10) {
    putchar('0' + first);
    return;
  }
  print(first / 10);
  putchar(first % 10 + '0');
}
template <class T>
inline void printsp(T first) {
  print(first);
  putchar(' ');
}
template <class T>
inline void println(T first) {
  print(first);
  putchar('\n');
}
template <class T, class U>
inline void print(T first, U second) {
  printsp(first);
  println(second);
}
template <class T, class U, class V>
inline void print(T first, U second, V z) {
  printsp(first);
  printsp(second);
  println(z);
}
int power(int a, int b, int m, int ans = 1) {
  for (; b; b >>= 1, a = 1LL * a * a % m)
    if (b & 1) ans = 1LL * ans * a % m;
  return ans;
}
char s[11];
pair<int, int> p[5111];
int first[5111 << 1], second[5111 << 1];
int nx, ny;
bool vst[5111][5111];
long long lx[5111], ly[5111];
long long ans;
int du[] = {-1, 0, 1, 0};
int dv[] = {0, 1, 0, -1};
void dfs(int u, int v) {
  vst[u][v] = 1;
  ans -= lx[u] * ly[v];
  for (int i = 0; i < 4; i++) {
    int uu = u + du[i], vv = v + dv[i];
    if (uu < 1 or vv < 1 or uu > nx or vv > ny) continue;
    if (vst[uu][vv]) continue;
    dfs(uu, vv);
  }
}
int main() {
  int n;
  cin >> n;
  p[0] = pair<int, int>(0, 0);
  for (int i = 1; i <= n; i++) {
    scanf("%s", s);
    int d;
    gn(d);
    first[nx++] = p[i - 1].first;
    second[ny++] = p[i - 1].second;
    p[i] = p[i - 1];
    if (s[0] == 'U') {
      p[i].second += d;
    }
    if (s[0] == 'D') {
      p[i].second -= d;
    }
    if (s[0] == 'R') {
      p[i].first += d;
    }
    if (s[0] == 'L') {
      p[i].first -= d;
    }
  }
  for (int i = 0; i <= n; i++) {
    for (int j = -1; j <= 1; j++)
      first[nx++] = p[i].first + j, second[ny++] = p[i].second + j;
  }
  sort(first, first + nx);
  sort(second, second + ny);
  nx = unique(first, first + nx) - first;
  ny = unique(second, second + ny) - second;
  for (int i = 0; i <= n; i++) {
    p[i].first = upper_bound(first, first + nx, p[i].first) - first;
    p[i].second = upper_bound(second, second + ny, p[i].second) - second;
  }
  for (int i = 0; i < n; i++) {
    if (p[i].first == p[i + 1].first) {
      int st = p[i].second, ed = p[i + 1].second;
      if (st > ed) swap(st, ed);
      for (int j = st; j <= ed; j++) vst[p[i].first][j] = 1;
    } else {
      int st = p[i].first, ed = p[i + 1].first;
      if (st > ed) swap(st, ed);
      for (int j = st; j <= ed; j++) vst[j][p[i].second] = 1;
    }
  }
  int totx = 0;
  for (int i = 1; i <= nx; i++) {
    if (i == 1)
      lx[i] = 1;
    else
      lx[i] = first[i - 1] - first[i - 2];
    totx += lx[i];
  }
  long long toty = 0;
  for (int i = 1; i <= ny; i++) {
    if (i == 1)
      ly[i] = 1;
    else
      ly[i] = second[i - 1] - second[i - 2];
    toty += ly[i];
  }
  ans = toty * totx;
  dfs(1, 1);
  println(ans);
  return 0;
}
