#include <bits/stdc++.h>
using namespace std;
const int N = 5000;
const long long inf = 1000001000;
struct data {
  long long x1, y1, x2, y2, v;
};
long long n, dxn, dyn, dx[N], dy[N], ans;
data line[N];
int bed[N][N];
void init() {
  cin >> n;
  long long tx = 0, ty = 0, lx = 0, ly = 0, x;
  char ch;
  for (int i = 1; i <= n; ++i) {
    cin >> ch >> x;
    if (ch == 'L') {
      tx = lx - x;
      ty = ly;
    }
    if (ch == 'R') {
      tx = lx + x;
      ty = ly;
    }
    if (ch == 'U') {
      tx = lx;
      ty = ly + x;
    }
    if (ch == 'D') {
      tx = lx;
      ty = ly - x;
    }
    if (lx <= tx && ly <= ty) {
      line[i].x1 = lx;
      line[i].y1 = ly;
      line[i].x2 = tx;
      line[i].y2 = ty;
      line[i].v = 1;
    } else {
      line[i].x1 = tx;
      line[i].y1 = ty;
      line[i].x2 = lx;
      line[i].y2 = ly;
      line[i].v = 1;
    }
    dx[++dxn] = line[i].x1;
    dy[++dyn] = line[i].y1;
    dx[++dxn] = line[i].x2 + 1;
    dy[++dyn] = line[i].y2 + 1;
    lx = tx;
    ly = ty;
  }
  line[++n].x1 = -inf;
  line[n].y1 = inf;
  line[n].x2 = inf;
  line[n].y2 = inf;
  line[n].v = -1;
  dx[++dxn] = line[n].x1;
  dy[++dyn] = line[n].y1;
  dx[++dxn] = line[n].x2 + 1;
  dy[++dyn] = line[n].y2 + 1;
  line[++n].x1 = -inf;
  line[n].y1 = -inf;
  line[n].x2 = inf;
  line[n].y2 = -inf;
  line[n].v = -1;
  dx[++dxn] = line[n].x1;
  dy[++dyn] = line[n].y1;
  dx[++dxn] = line[n].x2 + 1;
  dy[++dyn] = line[n].y2 + 1;
  line[++n].x1 = inf;
  line[n].y1 = -inf;
  line[n].x2 = inf;
  line[n].y2 = inf;
  line[n].v = -1;
  dx[++dxn] = line[n].x1;
  dy[++dyn] = line[n].y1;
  dx[++dxn] = line[n].x2 + 1;
  dy[++dyn] = line[n].y2 + 1;
  line[++n].x1 = -inf;
  line[n].y1 = -inf;
  line[n].x2 = -inf;
  line[n].y2 = inf;
  line[n].v = -1;
  dx[++dxn] = line[n].x1;
  dy[++dyn] = line[n].y1;
  dx[++dxn] = line[n].x2 + 1;
  dy[++dyn] = line[n].y2 + 1;
  sort(dx + 1, dx + 1 + dxn);
  dxn = unique(dx + 1, dx + 1 + dxn) - (dx + 1);
  sort(dy + 1, dy + 1 + dyn);
  dyn = unique(dy + 1, dy + 1 + dyn) - (dy + 1);
}
void work() {
  int tx, ty, lx, ly;
  for (int i = 1; i <= n; ++i) {
    lx = lower_bound(dx + 1, dx + 1 + dxn, line[i].x1) - dx;
    ly = lower_bound(dy + 1, dy + 1 + dyn, line[i].y1) - dy;
    tx = lower_bound(dx + 1, dx + 1 + dxn, line[i].x2 + 1) - dx;
    ty = lower_bound(dy + 1, dy + 1 + dyn, line[i].y2 + 1) - dy;
    for (int j = lx; j < tx; ++j)
      for (int k = ly; k < ty; ++k) bed[j][k] = line[i].v;
  }
}
bool check(int x, int y) {
  if (x < 1 || x >= dxn || y < 1 || y >= dyn) return 0;
  if (bed[x][y] != 0 && bed[x][y] != -1) return 0;
  return 1;
}
void dfs(int x, int y) {
  if (!check(x, y)) return;
  bed[x][y] = -2;
  dfs(x + 1, y);
  dfs(x, y + 1);
  dfs(x - 1, y);
  dfs(x, y - 1);
}
void print() {
  for (int i = 1; i < dxn; ++i)
    for (int j = 1; j < dyn; ++j)
      if (bed[i][j] == -1) dfs(i, j);
  for (int i = 1; i < dxn; ++i)
    for (int j = 1; j < dyn; ++j)
      if (bed[i][j] >= 0) {
        ans += (dx[i + 1] - dx[i]) * (dy[j + 1] - dy[j]);
      }
  cout << ans;
}
int main() {
  init();
  work();
  print();
}
