#include <bits/stdc++.h>
using namespace std;
bool debug = false;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
long long ln, lk, lm;
map<int, int> idx, idy;
vector<int> vx, vy;
int x[2105], y[2105];
int mp[2105][2105];
char ope[] = "URDL", oo;
int main() {
  scanf("%d", &n);
  x[0] = 0;
  y[0] = 0;
  for (int i = 1, d, j; i <= n; i++) {
    scanf(" %c %d", &oo, &d);
    for (j = 0; j < 4; j++)
      if (ope[j] == oo) break;
    x[i] = x[i - 1] + d * dx[j];
    y[i] = y[i - 1] + d * dy[j];
    idx[min(x[i - 1], x[i])];
    idx[max(x[i - 1], x[i]) + 1];
    idy[min(y[i - 1], y[i])];
    idy[max(y[i - 1], y[i]) + 1];
  }
  idx[-(1 << 30)];
  idy[-(1 << 30)];
  int cnt = 0;
  for (auto &p : idx) {
    p.second = cnt++;
    vx.push_back(p.first);
  }
  cnt = 0;
  for (auto &p : idy) {
    p.second = cnt++;
    vy.push_back(p.first);
  }
  for (int k = 1; k <= n; k++) {
    int sx = idx[min(x[k - 1], x[k])];
    int tx = idx[max(x[k - 1], x[k]) + 1];
    int sy = idy[min(y[k - 1], y[k])];
    int ty = idy[max(y[k - 1], y[k]) + 1];
    for (int i = sx; i < tx; ++i) {
      for (int j = sy; j < ty; ++j) {
        mp[i][j] = 1;
      }
    }
  }
  queue<pair<int, int>> q;
  q.push({0, 0});
  mp[0][0] = 2;
  while (!q.empty()) {
    auto p = q.front();
    q.pop();
    for (int(i) = 0; (i) < (int)(4); (i)++) {
      int tx = p.first + dx[i];
      int ty = p.second + dy[i];
      if (tx >= 0 && ty >= 0 && tx < idx.size() && ty < idy.size()) {
        if (mp[tx][ty] == 0) {
          mp[tx][ty] = 2;
          q.push({tx, ty});
        }
      }
    }
  }
  long long ans = 0;
  for (int(i) = 0; (i) < (int)(idx.size()); (i)++) {
    for (int(j) = 0; (j) < (int)(idy.size()); (j)++) {
      if (mp[i][j] != 2) {
        ans += (long long)(vx[i + 1] - vx[i]) * (vy[j + 1] - vy[j]);
      }
    }
  }
  printf("%lld\n", ans);
  return 0;
}
