#include <bits/stdc++.h>
using namespace std;
const int D[][2] = {{0, -1}, {0, 1}, {-1, 0}, {1, 0}};
const int N = 2005;
int mpd[256];
int n, op[N][2], tb[2][N];
int vi[N][N];
int qh(int i) { return i & 1 ? abs(tb[0][i + 1 >> 1] - tb[0][i >> 1]) - 1 : 1; }
int qw(int j) { return j & 1 ? abs(tb[1][j + 1 >> 1] - tb[1][j >> 1]) - 1 : 1; }
void Bfs() {
  queue<pair<int, int> > Q;
  Q.push((pair<int, int>){1, 1});
  vi[1][1] = 1;
  while (!Q.empty()) {
    pair<int, int> u = Q.front();
    Q.pop();
    int x = u.first, y = u.second;
    for (int d = 0; d < 4; ++d) {
      int xx = x + D[d][0], yy = y + D[d][1];
      if (xx > 0 && xx <= 2 * *tb[0] + 1 && yy > 0 && yy <= 2 * *tb[1] + 1 &&
          !vi[xx][yy] &&
          (xx == 1 || xx > 2 * *tb[0] || yy == 1 || yy > 2 * *tb[1] ||
           (D[d][0] ? qw(yy) : qh(xx)))) {
        Q.push((pair<int, int>){xx, yy});
        vi[xx][yy] = 1;
      }
    }
  }
}
int gmy = 1;
int main() {
  char c;
  int v[2] = {0, 0}, p[2], vv[2], pp[2], pa, t;
  long long ans = 1;
  mpd['U'] = 2;
  mpd['D'] = 3;
  mpd['L'] = 0;
  mpd['R'] = 1;
  tb[0][1] = tb[1][1] = 0;
  cin >> n;
  for (int t = 1; t <= n; ++t) {
    while (isspace(c = getchar()))
      ;
    cin >> pa;
    op[t][0] = c, op[t][1] = pa;
    for (int o = 0; o < 2; ++o) tb[o][t + 1] = v[o] += D[mpd[c]][o] * pa;
  }
  for (int o = 0; o < 2; ++o) {
    sort(tb[o] + 1, tb[o] + n + 2);
    *tb[o] = unique(tb[o] + 1, tb[o] + n + 2) - tb[o] - 1;
  }
  for (int o = 0; o < 2; ++o)
    p[o] = lower_bound(tb[o] + 1, tb[o] + *tb[o] + 1, v[o] = 0) - tb[o];
  vi[p[0] << 1][p[1] << 1] = ++gmy;
  for (int t = 1; t <= n; ++t) {
    c = op[t][0], pa = op[t][1];
    for (int o = 0; o < 2; ++o) {
      vv[o] = v[o] + D[mpd[c]][o] * pa;
      pp[o] = lower_bound(tb[o] + 1, tb[o] + *tb[o] + 1, vv[o]) - tb[o];
    }
    if (p[1] == pp[1]) {
      for (int i = pp[0]; i != p[0]; i -= D[mpd[c]][0]) {
        if (!vi[i << 1][p[1] << 1]) {
          vi[i << 1][p[1] << 1] = ++gmy;
          ans += 1;
        }
        if (!vi[i * 2 - D[mpd[c]][0]][p[1] << 1]) {
          vi[i * 2 - D[mpd[c]][0]][p[1] << 1] = ++gmy;
          ans += abs(tb[0][i] - tb[0][i - D[mpd[c]][0]]) - 1;
        }
      }
    } else {
      for (int j = pp[1]; j != p[1]; j -= D[mpd[c]][1]) {
        if (!vi[p[0] << 1][j << 1]) {
          vi[p[0] << 1][j << 1] = ++gmy;
          ans += 1;
        }
        if (!vi[p[0] << 1][j * 2 - D[mpd[c]][1]]) {
          vi[p[0] << 1][j * 2 - D[mpd[c]][1]] = ++gmy;
          ans += abs(tb[1][j] - tb[1][j - D[mpd[c]][1]]) - 1;
        }
      }
    }
    for (int o = 0; o < 2; ++o) v[o] = vv[o], p[o] = pp[o];
  }
  Bfs();
  for (int i = 1; i <= 2 * *tb[0]; ++i)
    for (int j = 1; j <= 2 * *tb[1]; ++j)
      if (!vi[i][j]) {
        vi[i][j] = -1LL * qh(i) * qw(j);
        ans += 1LL * qh(i) * qw(j);
      }
  cout << ans << endl;
}
