#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;
}
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, -1, 1};
int vst[2010][2010];
int qf, qb, q[2010 * 2010];
int X[2010], Y[2010];
int first[2010], second[2010];
int main() {
  int n, d;
  char c;
  scanf("%d", &n);
  int nx = 0, ny = 0;
  X[nx++] = 0, Y[ny++] = 0;
  X[nx++] = 1, Y[ny++] = 1;
  first[0] = 0, second[0] = 0;
  for (int i = 1; i <= n; i++) {
    scanf(" %c%d", &c, &d);
    int u = strchr("RLDU", c) - "RLDU";
    first[i] = first[i - 1] + dx[u] * d;
    second[i] = second[i - 1] + dy[u] * d;
    X[nx++] = first[i];
    X[nx++] = first[i] + 1;
    Y[ny++] = second[i];
    Y[ny++] = second[i] + 1;
  }
  sort(X, X + nx), nx = unique(X, X + nx) - X;
  sort(Y, Y + ny), ny = unique(Y, Y + ny) - Y;
  int preu, prev;
  for (int i = 0; i <= n; i++) {
    int u = lower_bound(X, X + nx, first[i]) - X + 1;
    int v = lower_bound(Y, Y + ny, second[i]) - Y + 1;
    if (i) {
      if (u == preu) {
        for (int j = min(v, prev); j <= max(prev, v); j++) vst[u][j] = 1;
      } else {
        for (int j = min(u, preu); j <= max(preu, u); j++) vst[j][v] = 1;
      }
    }
    preu = u, prev = v;
  }
  qf = qb = 0;
  q[qb++] = 0, q[qb++] = 0;
  vst[0][0] = 2;
  while (qf < qb) {
    int u = q[qf++], v = q[qf++];
    for (int i = 0; i < 4; i++) {
      int uu = u + dx[i], vv = v + dy[i];
      if ((uu < 0 || vv < 0 || uu >= nx + 1 || vv >= ny + 1) || vst[uu][vv])
        continue;
      vst[uu][vv] = 2;
      q[qb++] = uu, q[qb++] = vv;
    }
  }
  long long ans = 0, midans = 0, tot = 0;
  for (int i = 1; i < nx; i++) {
    for (int j = 1; j < ny; j++) {
      if (vst[i][j] != 2)
        ans += (long long)(Y[j] - Y[j - 1]) * (X[i] - X[i - 1]);
      else
        midans += (long long)(Y[j] - Y[j - 1]) * (X[i] - X[i - 1]);
    }
  }
  cout << ans << endl;
  return 0;
}
