#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, long long> > segx, segy;
vector<pair<pair<long long, long long>, pair<long long, long long> > > segment;
int matrix[1111 * 4][1111 * 4];
void add(long long x1, long long y1, long long x2, long long y2) {
  if (x1 > x2) swap(x1, x2);
  if (y1 > y2) swap(y1, y2);
  segment.push_back(make_pair(make_pair(x1, y1), make_pair(x2, y2)));
}
void dfs(int x, int y) {
  if (x < 0 || y < 0 || x >= segx.size() || y >= segy.size() ||
      matrix[x][y] != 0)
    return;
  matrix[x][y] = 2;
  dfs(x - 1, y);
  dfs(x + 1, y);
  dfs(x, y - 1);
  dfs(x, y + 1);
}
int main() {
  int n;
  cin >> n;
  long long sx = 0, sy = 0;
  long long tx, ty;
  segx.push_back(make_pair(-2e9, 0));
  segx.push_back(make_pair(2e9, 0));
  segy.push_back(make_pair(-2e9, 0));
  segy.push_back(make_pair(2e9, 0));
  segx.push_back(make_pair(0, 1));
  segy.push_back(make_pair(0, 1));
  for (int i = 1; i <= n; i++) {
    char d;
    long long mvstep;
    long long wx = 0, wy = 0;
    cin >> d >> mvstep;
    wx = (int)(d == 'R') - (int)(d == 'L');
    wy = (int)(d == 'D') - (int)(d == 'U');
    tx = sx + wx * mvstep;
    ty = sy + wy * mvstep;
    segx.push_back(make_pair(tx, 1));
    segy.push_back(make_pair(ty, 1));
    add(sx, sy, tx, ty);
    sx = tx;
    sy = ty;
  }
  sort(segx.begin(), segx.end());
  sort(segy.begin(), segy.end());
  segx.resize(unique(segx.begin(), segx.end()) - segx.begin());
  segy.resize(unique(segy.begin(), segy.end()) - segy.begin());
  int xsz = segx.size();
  int ysz = segy.size();
  for (int i = 0; i < xsz - 1; i++)
    if (segx[i + 1].first > 1 + segx[i].first) {
      segx.push_back(
          make_pair(segx[i].first + 1, segx[i + 1].first - segx[i].first - 1));
    }
  for (int i = 0; i < ysz - 1; i++)
    if (segy[i + 1].first > 1 + segy[i].first) {
      segy.push_back(
          make_pair(segy[i].first + 1, segy[i + 1].first - segy[i].first - 1));
    }
  sort(segx.begin(), segx.end());
  sort(segy.begin(), segy.end());
  for (int i = 0; i < n; i++) {
    int xsz = segx.size();
    int ysz = segy.size();
    int x1, x2, y1, y2;
    for (int j = 0; j < xsz; j++) {
      if (segx[j].first == segment[i].first.first) x1 = j;
      if (segx[j].first == segment[i].second.first) x2 = j;
    }
    for (int j = 0; j < ysz; j++) {
      if (segy[j].first == segment[i].first.second) y1 = j;
      if (segy[j].first == segment[i].second.second) y2 = j;
    }
    for (int j = x1; j <= x2; j++)
      for (int k = y1; k <= y2; k++) {
        matrix[j][k] = 1;
      }
  }
  dfs(0, 0);
  long long ans = 0;
  for (int j = 0; j < segx.size(); j++)
    for (int k = 0; k < segy.size(); k++) {
      if (matrix[j][k] != 2) {
        ans += segx[j].second * segy[k].second;
      }
    }
  cout << ans << endl;
  return 0;
}
