#include <bits/stdc++.h>
using namespace std;
const int maxn = 2000 + 85 - 69, maxnn = maxn * maxn;
vector<pair<int, int> > veca[maxn], veco[maxn], tmp;
pair<int, int> pos[maxn];
vector<int> xall, yall;
bool mark[maxn][maxn];
int n, xpos, ypos;
int mp[256];
int dx[4] = {-1, -0, +0, +1}, dy[4] = {-0, -1, +1, +0};
char dir[maxn];
int len[maxn];
const long long int Inf = 1.5e9;
long long int ans;
bool valid(int x, int y) {
  if (x < 0 or x >= ((int)(xall).size()) - 1 or y < 0 or
      y >= ((int)(yall).size()) - 1 or mark[x][y])
    return false;
  return true;
}
void dfs(int x, int y) {
  ans -= 1LL * (xall[x + 1] - xall[x]) * (yall[y + 1] - yall[y]);
  mark[x][y] = true;
  for (int i = 0; i < 4; i++) {
    int xx = x + dx[i], yy = y + dy[i];
    if (valid(xx, yy)) dfs(xx, yy);
  }
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  ans = 4 * Inf * Inf;
  mp['L'] = 0;
  mp['D'] = 1;
  mp['U'] = 2;
  mp['R'] = 3;
  tmp.reserve(1 << 12);
  cin >> n;
  xall.push_back(-Inf);
  xall.push_back(+Inf);
  yall.push_back(-Inf);
  yall.push_back(+Inf);
  xall.push_back(xpos);
  xall.push_back(xpos + 1);
  yall.push_back(ypos);
  yall.push_back(ypos + 1);
  for (int i = 0; i < n; i++) {
    cin >> dir[i] >> len[i];
    xpos += dx[mp[dir[i]]] * len[i];
    ypos += dy[mp[dir[i]]] * len[i];
    pos[i + 1] = {xpos, ypos};
    xall.push_back(xpos);
    xall.push_back(xpos + 1);
    yall.push_back(ypos);
    yall.push_back(ypos + 1);
  }
  sort(xall.begin(), xall.end());
  sort(yall.begin(), yall.end());
  xall.resize(unique(xall.begin(), xall.end()) - xall.begin());
  yall.resize(unique(yall.begin(), yall.end()) - yall.begin());
  for (int i = 0; i <= n; i++) {
    pos[i].first =
        lower_bound(xall.begin(), xall.end(), pos[i].first) - xall.begin();
    pos[i].second =
        lower_bound(yall.begin(), yall.end(), pos[i].second) - yall.begin();
    if (!i) continue;
    if (pos[i].first == pos[i - 1].first) {
      int st = min(pos[i].second, pos[i - 1].second),
          en = max(pos[i].second, pos[i - 1].second);
      for (int j = st; j <= en; j++) mark[pos[i].first][j] = true;
    } else {
      int st = min(pos[i].first, pos[i - 1].first),
          en = max(pos[i].first, pos[i - 1].first);
      for (int j = st; j <= en; j++) mark[j][pos[i].second] = true;
    }
  }
  dfs(0, 0);
  cout << ans << endl;
  return 0;
}
