#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2010;
const long long INF = 1ll << 47;
const long long way[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
struct rect {
  long long p1, q1, p2, q2;
} rec[MAXN];
int n, tot = 0;
int vis[MAXN][MAXN];
int lst[2], now[2];
map<long long, int> xpos, ypos;
vector<long long> x, y;
queue<pair<long long, long long> > q;
inline int max(int x, int y) { return x > y ? x : y; }
inline int min(int x, int y) { return x < y ? x : y; }
void adde(int ord) {
  char opt[3];
  int val;
  scanf("%s%d", opt, &val);
  switch (opt[0]) {
    case 'U': {
      now[0] = lst[0] - val;
      now[1] = lst[1];
      break;
    }
    case 'D': {
      now[0] = lst[0] + val;
      now[1] = lst[1];
      break;
    }
    case 'L': {
      now[0] = lst[0];
      now[1] = lst[1] - val;
      break;
    }
    case 'R': {
      now[0] = lst[0];
      now[1] = lst[1] + val;
      break;
    }
    default: {
      puts("Error");
      return;
    }
  }
  x.push_back(min(lst[0], now[0]));
  x.push_back(max(lst[0], now[0]) + 1);
  y.push_back(min(lst[1], now[1]));
  y.push_back(max(lst[1], now[1]) + 1);
  rec[ord] = (rect){min(lst[0], now[0]), min(lst[1], now[1]),
                    max(lst[0], now[0]) + 1, max(lst[1], now[1]) + 1};
  lst[0] = now[0];
  lst[1] = now[1];
}
int match(vector<long long> v, long long num) {
  return find(v.begin(), v.end(), num) - v.begin();
}
int main() {
  x.push_back(-INF);
  x.push_back(INF);
  y.push_back(-INF);
  y.push_back(INF);
  scanf("%d", &n);
  for (int i = 0; i < n; i++) adde(i);
  sort(x.begin(), x.end());
  sort(y.begin(), y.end());
  x.resize(unique(x.begin(), x.end()) - x.begin());
  y.resize(unique(y.begin(), y.end()) - y.begin());
  for (int i = 0; i < n; i++) {
    lst[0] = match(x, rec[i].p1);
    now[0] = match(x, rec[i].p2) - 1;
    lst[1] = match(y, rec[i].q1);
    now[1] = match(y, rec[i].q2) - 1;
    for (int j = lst[0]; j <= now[0]; j++)
      for (int k = lst[1]; k <= now[1]; k++) vis[j][k] = 1;
  }
  q.push(make_pair(0, 0));
  vis[0][0] = 2;
  while (!q.empty()) {
    pair<long long, long long> u, v;
    u = q.front();
    q.pop();
    for (int i = 0; i < 4; i++) {
      v = u;
      v.first += way[i][0];
      v.second += way[i][1];
      if (v.first >= 0 && v.first < x.size() && v.second >= 0 &&
          v.second < y.size() && vis[v.first][v.second] == 0) {
        vis[v.first][v.second] = 2;
        q.push(v);
      }
    }
  }
  long long ans = 0;
  for (int i = 0; i < x.size() - 1; i++)
    for (int j = 0; j < y.size() - 1; j++)
      if (vis[i][j] != 2)
        ans += (x[i + 1] - x[i]) * (long long)(y[j + 1] - y[j]);
  printf("%lld\n", ans);
  return 0;
}
