#include <bits/stdc++.h>
using namespace std;
template <typename T>
using V = vector<T>;
const long long B = 2e3 + 43;
int XX = -1, YY = -1;
bool done[B][B], doomed[B][B];
bool canGo(int x, int y) {
  return x <= XX && y <= YY && x >= 0 && y >= 0 && !done[x][y] && !doomed[x][y];
}
void dfs(int x = 0, int y = 0) {
  doomed[x][y] = true;
  if (canGo(x, y + 1)) dfs(x, y + 1);
  if (canGo(x, y - 1)) dfs(x, y - 1);
  if (canGo(x + 1, y)) dfs(x + 1, y);
  if (canGo(x - 1, y)) dfs(x - 1, y);
}
int ix[2 * B], iy[2 * B];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<pair<long long, long long> > P(n + 1);
  set<int> ex, ey;
  int cx = 0, cy = 0;
  ex.insert(cx), ey.insert(cy);
  ex.insert(cx - 1), ey.insert(cy - 1);
  P[0] = {0, 0};
  for (int i = 0; i < n; i++) {
    char f;
    int ds = 0;
    cin >> f >> ds;
    if (f == 'R') {
      cx += ds;
    }
    if (f == 'L') {
      cx -= ds;
    }
    if (f == 'U') {
      cy += ds;
    }
    if (f == 'D') {
      cy -= ds;
    }
    P[i + 1] = {cx, cy};
    ex.insert(cx), ey.insert(cy);
    ex.insert(cx - 1), ey.insert(cy - 1);
  }
  map<int, int> compx, compy;
  int ind = 0;
  for (int u : ex) {
    compx[u] = ind;
    ix[ind] = u;
    ind++;
  }
  XX = ind + 1;
  ind = 0;
  for (int u : ey) {
    compy[u] = ind;
    iy[ind] = u;
    ind++;
  }
  YY = ind + 1;
  for (auto &u : P) {
    u.first = compx[u.first];
    u.second = compy[u.second];
  }
  for (int i = 1; i < n + 1; i++) {
    int mnx = min(P[i].first, P[i - 1].first);
    int mxx = max(P[i].first, P[i - 1].first);
    for (int j = mnx; j <= mxx; j++) {
      done[j][P[i].second] = true;
    }
    int mny = min(P[i].second, P[i - 1].second);
    int mxy = max(P[i].second, P[i - 1].second);
    for (int j = mny; j <= mxy; j++) {
      done[P[i].first][j] = true;
    }
  }
  long long ans = 0;
  dfs();
  for (int i = 0; i < XX; i++) {
    for (int j = 0; j < YY; j++) {
      if (!doomed[i][j]) {
        ans += (long long)(ix[i] - ix[i - 1]) * (iy[j] - iy[j - 1]);
      }
    }
  }
  cout << ans << endl;
  return 0;
}
