#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2048;
const int DX[4] = {-1, 1, 0, 0};
const int DY[4] = {0, 0, -1, 1};
int n, x[MAXN], y[MAXN], r, c;
bool tag[MAXN][MAXN];
vector<int> disx, disy;
int main() {
  scanf("%d", &n);
  int xx = 0, yy = 0;
  x[0] = xx;
  y[0] = yy;
  for (int i = 1; i <= n; i++) {
    char d[8];
    int l;
    scanf("%s%d", d, &l);
    if (d[0] == 'R') {
      xx += l;
    } else if (d[0] == 'L') {
      xx -= l;
    } else if (d[0] == 'U') {
      yy += l;
    } else {
      yy -= l;
    }
    x[i] = xx;
    y[i] = yy;
  }
  for (int i = 0; i <= n; i++) {
    disx.push_back(x[i]);
    disx.push_back(x[i] + 1);
    disy.push_back(y[i]);
    disy.push_back(y[i] + 1);
  }
  sort(disx.begin(), disx.end());
  disx.erase(unique(disx.begin(), disx.end()), disx.end());
  sort(disy.begin(), disy.end());
  disy.erase(unique(disy.begin(), disy.end()), disy.end());
  for (int i = 0; i <= n; i++) {
    x[i] = lower_bound(disx.begin(), disx.end(), x[i]) - disx.begin();
    y[i] = lower_bound(disy.begin(), disy.end(), y[i]) - disy.begin();
  }
  long long res = 0;
  for (int i = 1; i <= n; i++) {
    if (x[i - 1] == x[i]) {
      for (int j = min(y[i - 1], y[i]); j <= max(y[i - 1], y[i]); j++) {
        if (!tag[x[i]][j]) {
          tag[x[i]][j] = true;
          res += disy[j + 1] - disy[j];
        }
      }
    } else {
      for (int j = min(x[i - 1], x[i]); j <= max(x[i - 1], x[i]); j++) {
        if (!tag[j][y[i]]) {
          tag[j][y[i]] = true;
          res += disx[j + 1] - disx[j];
        }
      }
    }
  }
  r = disx.size() - 1;
  c = disy.size() - 1;
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      if (tag[i][j]) continue;
      long long tmpres = 0;
      bool valid = true;
      queue<pair<int, int> > q;
      tag[i][j] = true;
      for (q.push(make_pair(i, j)); !q.empty(); q.pop()) {
        int x = q.front().first, y = q.front().second;
        tmpres += (long long)(disx[x + 1] - disx[x]) * (disy[y + 1] - disy[y]);
        if (x == 0 || x == r - 1 || y == 0 || y == c - 1) {
          valid = false;
        }
        for (int dir = 0; dir < 4; dir++) {
          int xx = x + DX[dir], yy = y + DY[dir];
          if (0 <= xx && xx < r && 0 <= yy && yy < c && !tag[xx][yy]) {
            tag[xx][yy] = true;
            q.push(make_pair(xx, yy));
          }
        }
      }
      if (valid) {
        res += tmpres;
      }
    }
  }
  printf("%I64d\n", res);
  return 0;
}
