#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int const N = 2222;
int const dx[] = {-1, 1, 0, 0};
int const dy[] = {0, 0, 1, -1};
vector<int> xs, ys, x, y;
bool v[N][N];
queue<pair<int, int>> q;
inline int D(char const x) {
  if (x == 'L') return 0;
  if (x == 'R') return 1;
  if (x == 'U') return 2;
  return 3;
}
template <typename T>
void uniq(T &x) {
  sort(begin(x), end(x));
  x.erase(unique(begin(x), end(x)), end(x));
}
template <typename T>
int ID(vector<T> xs, T x) {
  return lower_bound(begin(xs), end(xs), x) - begin(xs);
}
int main() {
  int n, d;
  char dir[2];
  scanf("%d", &n);
  x.push_back(0), y.push_back(0);
  for (int i = 0; i < n; ++i) {
    scanf("%s%d", dir, &d);
    int k = D(dir[0]), tx = x.back() + dx[k] * d, ty = y.back() + dy[k] * d;
    x.push_back(tx), y.push_back(ty);
  }
  for (int i = 0; i <= n; ++i) {
    xs.push_back(x[i]), xs.push_back(x[i] + 1);
    ys.push_back(y[i]), ys.push_back(y[i] + 1);
  }
  uniq(xs), uniq(ys);
  for (int i = 0; i < n; ++i) {
    int x1 = ID(xs, x[i]), y1 = ID(ys, y[i]);
    int x2 = ID(xs, x[i + 1]), y2 = ID(ys, y[i + 1]);
    int d1 = x1 < x2 ? 1 : -1, d2 = y1 < y2 ? 1 : -1;
    for (int x = x1; x != x2 + d1; x += d1)
      for (int y = y1; y != y2 + d2; y += d2) {
        v[x][y] = true;
      }
  }
  ll tot = 1ll * (xs.back() - xs.front()) * (ys.back() - ys.front());
  auto bx = minmax_element(begin(x), end(x));
  auto by = minmax_element(begin(y), end(y));
  int x1 = ID(xs, *bx.first), x2 = ID(xs, *bx.second);
  int y1 = ID(ys, *by.first), y2 = ID(ys, *by.second);
  for (int i = x1; i <= x2; ++i) {
    if (!v[i][y1]) v[i][y1] = true, q.push({i, y1});
    if (!v[i][y2]) v[i][y2] = true, q.push({i, y2});
  }
  for (int i = y1; i <= y2; ++i) {
    if (!v[x1][i]) v[x1][i] = true, q.push({x1, i});
    if (!v[x2][i]) v[x2][i] = true, q.push({x2, i});
  }
  int sx = (int)xs.size() - 1, sy = (int)ys.size() - 1;
  while (!q.empty()) {
    auto t = q.front();
    q.pop();
    int x = t.first, y = t.second;
    tot -= 1ll * (xs[x + 1] - xs[x]) * (ys[y + 1] - ys[y]);
    for (int k = 0; k < 4; ++k) {
      int tx = x + dx[k], ty = y + dy[k];
      if (0 <= tx && tx < sx && 0 <= ty && ty < sy && !v[tx][ty]) {
        v[tx][ty] = true;
        q.push({tx, ty});
      }
    }
  }
  printf("%I64d\n", tot);
  return 0;
}
