#include <bits/stdc++.h>
using namespace std;
int N;
int X[1010], Y[1010];
vector<int> Xs, Ys;
int x233333333, y233333333;
bool def[2010][2010], vis[2010][2010];
queue<pair<int, int> > Q;
int main() {
  scanf("%d", &N);
  X[0] = Y[0] = 0;
  int i, j;
  for (i = 1; i <= N; i++) {
    X[i] = X[i - 1];
    Y[i] = Y[i - 1];
    char d[4];
    int p;
    scanf("%s%d", d, &p);
    if (d[0] == 'L') X[i] -= p;
    if (d[0] == 'R') X[i] += p;
    if (d[0] == 'U') Y[i] -= p;
    if (d[0] == 'D') Y[i] += p;
  }
  Xs.clear();
  Xs.push_back(-1233333333);
  for (i = 0; i <= N; i++) {
    Xs.push_back(X[i]);
    Xs.push_back(X[i] + 1);
  }
  sort(Xs.begin(), Xs.end());
  Xs.resize(unique(Xs.begin(), Xs.end()) - Xs.begin());
  Ys.clear();
  Ys.push_back(-1233333333);
  for (i = 0; i <= N; i++) {
    Ys.push_back(Y[i]);
    Ys.push_back(Y[i] + 1);
  }
  sort(Ys.begin(), Ys.end());
  Ys.resize(unique(Ys.begin(), Ys.end()) - Ys.begin());
  x233333333 = Xs.size();
  y233333333 = Ys.size();
  for (i = 0; i <= x233333333 - 1; i++)
    for (j = 0; j <= y233333333 - 1; j++) def[i][j] = vis[i][j] = false;
  for (i = 1; i <= N; i++)
    if (X[i] == X[i - 1]) {
      int u = lower_bound(Xs.begin(), Xs.end(), X[i]) - Xs.begin();
      int vs =
          lower_bound(Ys.begin(), Ys.end(), min(Y[i], Y[i - 1])) - Ys.begin();
      int ve =
          upper_bound(Ys.begin(), Ys.end(), max(Y[i], Y[i - 1])) - Ys.begin();
      for (j = vs; j <= ve - 1; j++) def[u][j] = true;
    } else {
      int us =
          lower_bound(Xs.begin(), Xs.end(), min(X[i], X[i - 1])) - Xs.begin();
      int ue =
          upper_bound(Xs.begin(), Xs.end(), max(X[i], X[i - 1])) - Xs.begin();
      int v = lower_bound(Ys.begin(), Ys.end(), Y[i]) - Ys.begin();
      for (j = us; j <= ue - 1; j++) def[j][v] = true;
    }
  while (Q.size()) Q.pop();
  vis[0][0] = true;
  Q.push(make_pair(0, 0));
  while (Q.size()) {
    pair<int, int> h = Q.front();
    Q.pop();
    if ((h.first - 1 >= 0) && (!def[h.first - 1][h.second]) &&
        (!vis[h.first - 1][h.second])) {
      vis[h.first - 1][h.second] = true;
      Q.push(make_pair(h.first - 1, h.second));
    }
    if ((h.first + 1 < x233333333) && (!def[h.first + 1][h.second]) &&
        (!vis[h.first + 1][h.second])) {
      vis[h.first + 1][h.second] = true;
      Q.push(make_pair(h.first + 1, h.second));
    }
    if ((h.second - 1 >= 0) && (!def[h.first][h.second - 1]) &&
        (!vis[h.first][h.second - 1])) {
      vis[h.first][h.second - 1] = true;
      Q.push(make_pair(h.first, h.second - 1));
    }
    if ((h.second + 1 < y233333333) && (!def[h.first][h.second + 1]) &&
        (!vis[h.first][h.second + 1])) {
      vis[h.first][h.second + 1] = true;
      Q.push(make_pair(h.first, h.second + 1));
    }
  }
  long long ans = 0;
  for (i = 1; i <= x233333333 - 2; i++)
    for (j = 1; j <= y233333333 - 2; j++)
      if (!vis[i][j]) ans += 1LL * (Xs[i + 1] - Xs[i]) * (Ys[j + 1] - Ys[j]);
  cout << ans << endl;
}
