#include <bits/stdc++.h>
using namespace std;
const int DIM = 3000;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, 1, 0, -1};
char mrk[DIM][DIM];
vector<int> lstX, lstY;
pair<int, int> que[DIM * DIM];
pair<char, int> mut[DIM];
void add(pair<int, int> pos) {
  for (int d = 0; d <= 1; ++d) {
    lstX.push_back(pos.first + d);
    lstY.push_back(pos.second + d);
  }
}
int findX(int x) {
  return lower_bound(lstX.begin(), lstX.end(), x) - lstX.begin();
}
int findY(int y) {
  return lower_bound(lstY.begin(), lstY.end(), y) - lstY.begin();
}
void mark(pair<int, int> pos) {
  pair<int, int> npos = make_pair(findX(pos.first), findY(pos.second));
  mrk[npos.first][npos.second] = -1;
}
int main(void) {
  int n;
  cin >> n;
  pair<int, int> pos(0, 0);
  lstX.push_back(-2e9);
  lstX.push_back(2e9);
  lstY.push_back(-2e9);
  lstY.push_back(2e9);
  add(pos);
  for (int i = 1; i <= n; ++i) {
    cin >> mut[i].first >> mut[i].second;
    if (mut[i].first == 'U') pos.first += mut[i].second;
    if (mut[i].first == 'R') pos.second += mut[i].second;
    if (mut[i].first == 'D') pos.first -= mut[i].second;
    if (mut[i].first == 'L') pos.second -= mut[i].second;
    add(pos);
  }
  sort(lstX.begin(), lstX.end());
  lstX.resize(unique(lstX.begin(), lstX.end()) - lstX.begin());
  sort(lstY.begin(), lstY.end());
  lstY.resize(unique(lstY.begin(), lstY.end()) - lstY.begin());
  pos = make_pair(0, 0);
  for (int i = 1; i <= n; ++i) {
    if (mut[i].first == 'U') {
      int px1 = findX(pos.first), px2 = findX(pos.first + mut[i].second),
          py = findY(pos.second);
      for (; px1 <= px2; ++px1) mrk[px1][py] = -1;
      pos.first += mut[i].second;
    }
    if (mut[i].first == 'D') {
      int px1 = findX(pos.first), px2 = findX(pos.first - mut[i].second),
          py = findY(pos.second);
      for (; px1 >= px2; --px1) mrk[px1][py] = -1;
      pos.first -= mut[i].second;
    }
    if (mut[i].first == 'R') {
      int px = findX(pos.first), py1 = findY(pos.second),
          py2 = findY(pos.second + mut[i].second);
      for (; py1 <= py2; ++py1) mrk[px][py1] = -1;
      pos.second += mut[i].second;
    }
    if (mut[i].first == 'L') {
      int px = findX(pos.first), py1 = findY(pos.second),
          py2 = findY(pos.second - mut[i].second);
      for (; py1 >= py2; --py1) mrk[px][py1] = -1;
      pos.second -= mut[i].second;
    }
  }
  que[0] = make_pair(0, 0);
  mrk[0][0] = 1;
  for (int st = 0, en = 0; st <= en; ++st) {
    pair<int, int> pos = que[st];
    for (int d = 0; d < 4; ++d) {
      pair<int, int> npos = make_pair(pos.first + dx[d], pos.second + dy[d]);
      if (npos.first < 0 or npos.first >= lstX.size()) continue;
      if (npos.second < 0 or npos.second >= lstY.size()) continue;
      if (mrk[npos.first][npos.second] == 0) {
        mrk[npos.first][npos.second] = 1;
        que[++en] = npos;
      }
    }
  }
  long long ans = 0;
  for (int i = 0; i < lstX.size(); ++i)
    for (int j = 0; j < lstY.size(); ++j)
      if (mrk[i][j] <= 0)
        ans += 1LL * (lstX[i + 1] - lstX[i]) * (lstY[j + 1] - lstY[j]);
  cout << ans;
  return 0;
}
