#include <bits/stdc++.h>
using namespace std;
long long x[1010], y[1010];
long long us[3010][3010];
vector<long long> xs, ys;
void fill(long long x1, long long y1, long long x2, long long y2) {
  x1 = lower_bound(xs.begin(), xs.end(), x1) - xs.begin();
  x2 = lower_bound(xs.begin(), xs.end(), x2) - xs.begin();
  y1 = lower_bound(ys.begin(), ys.end(), y1) - ys.begin();
  y2 = lower_bound(ys.begin(), ys.end(), y2) - ys.begin();
  if (x1 > x2) swap(x1, x2);
  if (y1 > y2) swap(y1, y2);
  for (long long i = x1; i <= x2; i++)
    for (long long j = y1; j <= y2; j++) us[i][j] = 1;
}
long long u[] = {-1, 0, 0, 1}, v[] = {0, -1, 1, 0};
void dfs(long long x, long long y) {
  if (x < 0 || y < 0 || x >= xs.size() || y >= ys.size() || us[x][y]) return;
  us[x][y] = 2;
  for (long long k = 0; k < (4); k++) dfs(x + u[k], y + v[k]);
}
int main() {
  long long n;
  while (scanf("%I64d", &n) == 1) {
    long long cx = 0, cy = 0, p;
    char c;
    xs.clear();
    ys.clear();
    for (long long i = 0; i < (n + 1); i++) {
      for (long long k = 0; k < (3); k++) {
        xs.push_back(cx + k - 1);
        ys.push_back(cy + k - 1);
      }
      if (i == n) break;
      scanf(" %c %I64d", &c, &p);
      if (c == 'R') cx += p;
      if (c == 'L') cx -= p;
      if (c == 'U') cy -= p;
      if (c == 'D') cy += p;
      x[i + 1] = cx;
      y[i + 1] = cy;
    }
    sort(xs.begin(), xs.end());
    sort(ys.begin(), ys.end());
    xs.erase(unique(xs.begin(), xs.end()), xs.end());
    ys.erase(unique(ys.begin(), ys.end()), ys.end());
    memset(us, 0, sizeof(us));
    for (long long i = 0; i < (n); i++) fill(x[i], y[i], x[i + 1], y[i + 1]);
    dfs(0, 0);
    long long res = 0;
    for (long long i = 0; i < (xs.size() - 1); i++)
      for (long long j = 0; j < (ys.size() - 1); j++)
        if (us[i][j] < 2) res += (xs[i + 1] - xs[i]) * (ys[j + 1] - ys[j]);
    printf("%I64d\n", res);
  }
  return 0;
}
