#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T sqr(T x) {
  return x * x;
}
template <class T>
inline void upmin(T &t, T tmp) {
  if (t > tmp) t = tmp;
}
template <class T>
inline void upmax(T &t, T tmp) {
  if (t < tmp) t = tmp;
}
inline int sgn(double x) {
  if (abs(x) < 1e-9) return 0;
  return (x > 0) ? 1 : -1;
}
const double Pi = acos(-1.0);
int gint() {
  int res = 0;
  bool neg = 0;
  char z;
  for (z = getchar(); z != EOF && z != '-' && !isdigit(z); z = getchar())
    ;
  if (z == EOF) return 0;
  if (z == '-') {
    neg = 1;
    z = getchar();
  }
  for (; z != EOF && isdigit(z); res = res * 10 + z - '0', z = getchar())
    ;
  return (neg) ? -res : res;
}
long long gll() {
  long long res = 0;
  bool neg = 0;
  char z;
  for (z = getchar(); z != EOF && z != '-' && !isdigit(z); z = getchar())
    ;
  if (z == EOF) return 0;
  if (z == '-') {
    neg = 1;
    z = getchar();
  }
  for (; z != EOF && isdigit(z); res = res * 10 + z - '0', z = getchar())
    ;
  return (neg) ? -res : res;
}
const int maxn = 1100;
int n;
int vx[maxn], vy[maxn];
int X[3 * maxn], Y[3 * maxn], cx, cy;
int mp[3 * maxn][3 * maxn];
void add(int x, int y) {
  X[++cx] = x - 1;
  X[++cx] = x;
  X[++cx] = x + 1;
  Y[++cy] = y - 1;
  Y[++cy] = y;
  Y[++cy] = y + 1;
}
int find(int *x, int n, int v) { return lower_bound(x + 1, x + n + 1, v) - x; }
void dfs(int x, int y) {
  if (x < 0 || x > cx + 1 || y < 0 || y > cy + 1 || mp[x][y]) return;
  mp[x][y] = 2;
  dfs(x + 1, y);
  dfs(x - 1, y);
  dfs(x, y + 1);
  dfs(x, y - 1);
}
int main() {
  int i, j, k, x = 0, y = 0;
  add(x, y);
  n = gint();
  for (i = (1); i <= (n); i++) {
    char ty = getchar();
    int t = gint();
    if (ty == 'R') x += t;
    if (ty == 'L') x -= t;
    if (ty == 'U') y += t;
    if (ty == 'D') y -= t;
    add(x, y);
    vx[i] = x;
    vy[i] = y;
  }
  sort(X + 1, X + cx + 1);
  sort(Y + 1, Y + cy + 1);
  cx = unique(X + 1, X + cx + 1) - X - 1;
  cy = unique(Y + 1, Y + cy + 1) - Y - 1;
  for (i = (1); i <= (n); i++) {
    int sx = find(X, cx, vx[i - 1]), sy = find(Y, cy, vy[i - 1]),
        tx = find(X, cx, vx[i]), ty = find(Y, cy, vy[i]);
    for (j = (min(sx, tx)); j <= (max(sx, tx)); j++)
      for (k = (min(sy, ty)); k <= (max(sy, ty)); k++) mp[j][k] = 1;
  }
  dfs(0, 0);
  long long ans = 0;
  for (i = (1); i <= (cx); i++)
    for (j = (1); j <= (cy); j++)
      if (mp[i][j] != 2)
        ans += (long long)(X[i] - X[i - 1]) * (Y[j] - Y[j - 1]);
  cout << ans << endl;
}
