#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:50000000")
using namespace std;
long long ans, ax, ay, newx, newy, j, fnx, fny, stx, sty, minx, miny, i, n;
long long D[10000];
char C[10000];
vector<long long> X, Y;
map<long long, long long> mx, my, getx, gety;
vector<pair<long long, long long> > A, B;
long long kix[3000][3000], F[3000][3000];
long long dx[4] = {1, -1, 0, 0};
long long dy[4] = {0, 0, -1, 1};
queue<pair<long long, long long> > q;
int main() {
  cin >> n;
  for (i = 1; i <= n; i++) cin >> C[i] >> D[i];
  minx = 0;
  miny = 0;
  stx = 0;
  sty = 0;
  X.push_back(0);
  Y.push_back(0);
  mx[0] = 1;
  my[0] = 1;
  for (i = 1; i <= n; i++) {
    if (C[i] == 'L') stx -= D[i];
    if (C[i] == 'R') stx += D[i];
    if (C[i] == 'D') sty -= D[i];
    if (C[i] == 'U') sty += D[i];
    if (mx[stx] == 0) {
      mx[stx] = 1;
      X.push_back(stx);
    }
    if (my[sty] == 0) {
      my[sty] = 1;
      Y.push_back(sty);
    }
    minx = (minx < stx ? minx : stx);
    miny = (miny < sty ? miny : sty);
  }
  sort(X.begin(), X.end());
  sort(Y.begin(), Y.end());
  for (i = 0; i < X.size(); i++) X[i] += -minx + 2;
  for (i = 0; i < Y.size(); i++) Y[i] += -miny + 2;
  A.push_back(make_pair(1, 1));
  B.push_back(make_pair(1, 1));
  getx[1] = 0;
  gety[1] = 0;
  for (i = 0; i < X.size(); i++) {
    A.push_back(make_pair(X[i], X[i]));
    getx[X[i]] = A.size() - 1;
    if (i < X.size() - 1)
      if (X[i] < X[i + 1] - 1) A.push_back(make_pair(X[i] + 1, X[i + 1] - 1));
  }
  for (i = 0; i < Y.size(); i++) {
    B.push_back(make_pair(Y[i], Y[i]));
    gety[Y[i]] = B.size() - 1;
    if (i < Y.size() - 1)
      if (Y[i] < Y[i + 1] - 1) B.push_back(make_pair(Y[i] + 1, Y[i + 1] - 1));
  }
  A.push_back(make_pair(X[X.size() - 1] + 1, X[X.size() - 1] + 1));
  B.push_back(make_pair(Y[Y.size() - 1] + 1, Y[Y.size() - 1] + 1));
  getx[X[X.size() - 1] + 1] = A.size();
  getx[Y[Y.size() - 1] + 1] = B.size();
  stx = -minx + 2;
  sty = -miny + 2;
  for (i = 1; i <= n; i++) {
    fnx = stx;
    fny = sty;
    if (C[i] == 'L') fnx -= D[i];
    if (C[i] == 'R') fnx += D[i];
    if (C[i] == 'D') fny -= D[i];
    if (C[i] == 'U') fny += D[i];
    if (C[i] == 'R')
      for (j = getx[stx]; j <= getx[fnx]; j++) {
        F[j][gety[sty]] = 1;
      }
    if (C[i] == 'L')
      for (j = getx[stx]; j >= getx[fnx]; j--) F[j][gety[sty]] = 1;
    if (C[i] == 'U')
      for (j = gety[sty]; j <= gety[fny]; j++) F[getx[stx]][j] = 1;
    if (C[i] == 'D')
      for (j = gety[sty]; j >= gety[fny]; j--) F[getx[stx]][j] = 1;
    stx = fnx;
    sty = fny;
  }
  q.push(make_pair(0, 0));
  kix[0][0] = 1;
  while (!q.empty()) {
    ax = q.front().first;
    ay = q.front().second;
    q.pop();
    for (i = 0; i < 4; i++) {
      newx = ax + dx[i];
      newy = ay + dy[i];
      if (newx >= 0 && newx < A.size() && newy >= 0 && newy < B.size())
        if (!kix[newx][newy] && F[newx][newy] == 0) {
          kix[newx][newy] = 1;
          q.push(make_pair(newx, newy));
        }
    }
  }
  for (i = 0; i < A.size(); i++)
    for (j = 0; j < B.size(); j++)
      if (!kix[i][j])
        ans += (A[i].second - A[i].first + 1) * (B[j].second - B[j].first + 1);
  cout << ans << endl;
}
