#include <bits/stdc++.h>
using namespace std;
struct rectangle {
  int x1, x2;
  int y1, y2;
  rectangle(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};
vector<rectangle> v;
int n, x, y, X, Y;
int xm[2005], ym[2005];
bool obs[2005][2005], a[2005][2005];
map<int, int> mx, my;
void dfs(int x, int y) {
  if (x < 0 || x >= X || y < 0 || y >= Y || obs[x][y] || a[x][y]) return;
  a[x][y] = true;
  dfs(x + 1, y);
  dfs(x - 1, y);
  dfs(x, y + 1);
  dfs(x, y - 1);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie();
  cout.tie();
  cout << setprecision(20);
  cin >> n;
  for (int i = 0; i < (n); i++) {
    char dir;
    int d;
    cin >> dir >> d;
    if (dir == 'L') {
      rectangle r = {x - d, y, x + 1, y + 1};
      v.push_back(r);
      x -= d;
    }
    if (dir == 'R') {
      rectangle r = {x, y, x + d + 1, y + 1};
      v.push_back(r);
      x += d;
    }
    if (dir == 'U') {
      rectangle r = {x, y, x + 1, y + d + 1};
      v.push_back(r);
      y += d;
    }
    if (dir == 'D') {
      rectangle r = {x, y - d, x + 1, y + 1};
      v.push_back(r);
      y -= d;
    }
  }
  for (int i = 0; i < (n); i++) {
    mx[v[i].x1] = mx[v[i].x2] = 0;
    my[v[i].y1] = my[v[i].y2] = 0;
  }
  for (auto &it : mx) {
    it.second = X;
    xm[X++] = it.first;
  }
  for (auto &it : my) {
    it.second = Y;
    ym[Y++] = it.first;
  }
  --X, --Y;
  for (int i = 0; i < (n); i++) {
    int x1 = mx[v[i].x1], x2 = mx[v[i].x2], y1 = my[v[i].y1], y2 = my[v[i].y2];
    for (int j = x1; j < x2; ++j)
      for (int k = y1; k < y2; ++k) obs[j][k] = true;
  }
  for (int i = 0; i < (X); i++)
    for (int j = 0; j < (Y); j++)
      if (!i || i == X - 1 || !j || j == Y - 1) dfs(i, j);
  long long ans = 0;
  for (int i = 0; i < (X); i++)
    for (int j = 0; j < (Y); j++)
      if (!a[i][j]) {
        long long dx = xm[i + 1] - xm[i], dy = ym[j + 1] - ym[j];
        ans += dx * dy;
      }
  cout << ans << endl;
  return 0;
}
