#include <bits/stdc++.h>
using namespace std;
const int inf = 0x20202020;
const int mod = 1000000007;
template <class T>
inline void read(T &x) {
  bool fu = 0;
  char c;
  for (c = getchar(); c <= 32; c = getchar())
    ;
  if (c == '-') fu = 1, c = getchar();
  for (x = 0; c > 32; c = getchar()) x = x * 10 + c - '0';
  if (fu) x = -x;
};
template <class T>
inline void read(T &x, T &y) {
  read(x);
  read(y);
}
template <class T>
inline void read(T &x, T &y, T &z) {
  read(x);
  read(y);
  read(z);
}
template <class T>
inline void read(T &x, T &y, T &z, T &q) {
  read(x);
  read(y);
  read(z);
  read(q);
}
const int DX[] = {1, 0, -1, 0}, DY[] = {0, 1, 0, -1};
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
long long powmod(long long a, long long b, long long mod) {
  long long res = 1;
  a %= mod;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
const int N = 3333, M = 111111;
int l, m, n, t, C, xtot, ytot, posx, posy, vis[N][N];
long long x, y, ans, lenx[N], leny[N];
map<long long, int> SX, SY;
struct zcc {
  int x, y;
} a[N];
char s[9];
inline long long calc(const int &x, const int &y) {
  if (x < 1 || x > xtot - 1 || y < 1 || y > ytot - 1) return 0;
  return (lenx[x + 1] - lenx[x]) * (leny[y + 1] - leny[y]);
  if ((x & 1) && (y & 1)) {
    return (lenx[x + 1] - lenx[x - 1] - 1) * (leny[y + 1] - leny[y - 1] - 1);
  } else if (x & 1) {
    return lenx[x + 1] - lenx[x - 1] - 1;
  } else if (y & 1) {
    return leny[y + 1] - leny[y - 1] - 1;
  } else
    return 1;
}
queue<pair<int, int> > Q;
void fill() {
  Q.push(make_pair(0, 0));
  while (Q.size()) {
    pair<int, int> k = Q.front();
    Q.pop();
    for (int i = (0); i <= (3); ++i)
      if ((0 <= k.first + DX[i] && k.first + DX[i] <= xtot &&
           0 <= k.second + DY[i] && k.second + DY[i] <= ytot) &&
          !vis[k.first + DX[i]][k.second + DY[i]]) {
        vis[k.first + DX[i]][k.second + DY[i]] = 2;
        Q.push(make_pair(k.first + DX[i], k.second + DY[i]));
      }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = (1); i <= (n); ++i) {
    scanf("%s%d", s, &a[i].y);
    if (s[0] == 'U') a[i].x = 0, y += a[i].y;
    if (s[0] == 'D') a[i].x = 1, y -= a[i].y;
    if (s[0] == 'L') a[i].x = 2, x -= a[i].y;
    if (s[0] == 'R') a[i].x = 3, x += a[i].y;
    SX[x] = SY[y] = SX[x - 1] = SY[y - 1] = SX[x + 1] = SY[y + 1] = 1;
  }
  SX[-1ll << 60] = SX[1ll << 60] = SY[-1ll << 60] = SY[1ll << 60] = SX[0] =
      SY[0] = SX[1] = SY[1] = SX[-1] = SY[-1] = 1;
  for (__typeof((SX).end()) it = SX.begin(); it != SX.end(); it++)
    it->second = ++xtot, lenx[xtot] = it->first;
  for (__typeof((SY).end()) it = SY.begin(); it != SY.end(); it++)
    it->second = ++ytot, leny[ytot] = it->first;
  xtot++;
  ytot++;
  posx = SX[0];
  posy = SY[0];
  x = 0;
  y = 0;
  vis[posx][posy] = 1;
  for (int i = (1); i <= (n); ++i) {
    if (a[i].x == 0) y += a[i].y;
    if (a[i].x == 1) y -= a[i].y;
    if (a[i].x == 2) x -= a[i].y;
    if (a[i].x == 3) x += a[i].y;
    int tmpx = SX[x], tmpy = SY[y];
    while (posx < tmpx) ++posx, vis[posx][posy] = 1;
    while (posx > tmpx) --posx, vis[posx][posy] = 1;
    while (posy < tmpy) ++posy, vis[posx][posy] = 1;
    while (posy > tmpy) --posy, vis[posx][posy] = 1;
  }
  fill();
  for (int i = (1); i <= (xtot - 1); ++i)
    for (int j = (1); j <= (ytot - 1); ++j)
      if (vis[i][j] != 2) ans += calc(i, j);
  printf("%I64d\n", ans);
  return 0;
}
