#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, long long> > path;
vector<long long> x, y;
bool mp[3050][3050];
bool used[3050][3050];
int n;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int ord(long long g, vector<long long> &arr) {
  int l = 0, r = arr.size() - 1, mid, t;
  while (l <= r) {
    mid = l + r >> 1;
    if (arr[mid] == g) return mid;
    if (arr[mid] < g)
      l = mid + 1;
    else
      r = mid - 1;
  }
  return -1;
}
queue<pair<int, int> > q;
int main() {
  cin >> n;
  char ad;
  int ader;
  path.push_back(make_pair(0LL, 0LL));
  for (int i = 0; i < n; i++) {
    pair<long long, long long> np = path.back();
    cin >> ad >> ader;
    if (ad == 'L') np.first -= ader;
    if (ad == 'R') np.first += ader;
    if (ad == 'U') np.second += ader;
    if (ad == 'D') np.second -= ader;
    path.push_back(np);
    x.push_back(max(path[i + 1].first, path[i].first) + 1);
    x.push_back(min(path[i + 1].first, path[i].first));
    y.push_back(max(path[i + 1].second, path[i].second) + 1);
    y.push_back(min(path[i + 1].second, path[i].second));
  }
  x.push_back(100000000000LL);
  x.push_back(-100000000000LL);
  y.push_back(100000000000LL);
  y.push_back(-100000000000LL);
  sort(x.begin(), x.end());
  sort(y.begin(), y.end());
  x.erase(unique(x.begin(), x.end()), x.end());
  y.erase(unique(y.begin(), y.end()), y.end());
  for (int i = 0; i < n; i++) {
    int lx = ord(min(path[i].first, path[i + 1].first), x);
    int rx = ord(max(path[i].first, path[i + 1].first) + 1, x);
    int ly = ord(min(path[i].second, path[i + 1].second), y);
    int ry = ord(max(path[i].second, path[i + 1].second) + 1, y);
    for (int kx = lx; kx < rx; kx++)
      for (int ky = ly; ky < ry; ky++) {
        mp[kx][ky] = 1;
      }
  }
  used[0][0] = true;
  q.push(make_pair(0, 0));
  while (!q.empty()) {
    pair<int, int> now = q.front(), nxt;
    q.pop();
    for (int i = 0; i < 4; i++) {
      nxt = make_pair(now.first + dx[i], now.second + dy[i]);
      if (nxt.first >= 0 && nxt.second >= 0 && nxt.first <= x.size() + 10 &&
          nxt.second <= y.size() + 10)
        if (!used[nxt.first][nxt.second] && !mp[nxt.first][nxt.second]) {
          q.push(nxt);
          used[nxt.first][nxt.second] = true;
        }
    }
  }
  long long ans = 0LL;
  for (int i = 0; i <= x.size(); i++) {
    for (int j = 0; j <= y.size(); j++) {
      if (!used[i][j]) {
        ans += (x[i + 1] - x[i]) * (y[j + 1] - y[j]);
      }
    }
  }
  cout << ans << endl;
}
