#include <bits/stdc++.h>
using namespace std;
string dir = "LRUD";
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, 1, -1};
map<long long, long long> xs;
map<long long, long long> ys;
map<long long, long long> revx, revy;
map<long long, long long> wx, wy;
int mat[2050][2050];
int main() {
  int n;
  int v;
  char d;
  scanf("%d\n", &n);
  long long curx = 0, cury = 0;
  xs[curx] = ys[cury] = 0;
  vector<pair<int, int> > moves;
  for (int i = 0; i < n; ++i) {
    scanf(" %c %d", &d, &v);
    moves.push_back(make_pair(dir.find(d), v));
    curx += dx[dir.find(d)] * v;
    cury += dy[dir.find(d)] * v;
    xs[curx] = ys[cury] = 0;
  }
  int szx, szy;
  int prev = xs.begin()->first - 2;
  int cur = 0;
  for (map<long long, long long>::iterator it = xs.begin(); it != xs.end();
       it++) {
    if (it->first - prev > 1) {
      revx[cur] = 1ll << 60;
      wx[cur++] = it->first - prev - 1;
    }
    prev = it->first;
    it->second = cur;
    wx[cur] = 1;
    revx[cur++] = it->first;
  }
  revx[cur++] = 1ll << 60;
  szx = cur;
  cur = 0;
  prev = ys.begin()->first - 2;
  for (map<long long, long long>::iterator it = ys.begin(); it != ys.end();
       it++) {
    if (it->first - prev > 1) {
      wy[cur] = it->first - prev - 1;
      revy[cur++] = 1ll << 60;
    }
    prev = it->first;
    it->second = cur;
    wy[cur] = 1;
    revy[cur++] = it->first;
  }
  revy[cur++] = 1ll << 60;
  szy = cur;
  curx = xs[0];
  cury = ys[0];
  for (int i = 0; i < n; ++i) {
    long long nx = revx[curx] + dx[moves[i].first] * moves[i].second;
    long long ny = revy[cury] + dy[moves[i].first] * moves[i].second;
    nx = xs[nx];
    ny = ys[ny];
    for (int cx = curx, cy = cury; cx != nx || cy != ny;
         cx += dx[moves[i].first], cy += dy[moves[i].first]) {
      mat[cx][cy] = 1;
    }
    mat[nx][ny] = 1;
    curx = nx;
    cury = ny;
  }
  queue<pair<int, int> > Q;
  mat[0][0] = 2;
  Q.push(make_pair(0, 0));
  pair<int, int> cc, c;
  while (!Q.empty()) {
    cc = Q.front();
    Q.pop();
    for (int d = 0; d < 4; ++d) {
      c.first = cc.first + dx[d];
      c.second = cc.second + dy[d];
      if (c.first >= 0 && c.first < szx && c.second >= 0 && c.second < szy &&
          mat[c.first][c.second] == 0) {
        mat[c.first][c.second] = 2;
        Q.push(c);
      }
    }
  }
  long long res = 0;
  for (int i = 0; i < szx; ++i) {
    for (int j = 0; j < szy; ++j) {
      if (mat[i][j] != 2) res += wx[i] * wy[j];
    }
  }
  cout << res << endl;
  return 0;
}
