#include <bits/stdc++.h>
using namespace std;
bool debug = false;
struct line {
  int x1, y1, x2, y2;
  line(int a, int b, int c, int d) {
    if (a > c) swap(a, c);
    if (b > d) swap(b, d);
    x1 = a;
    y1 = b;
    x2 = c;
    y2 = d;
    if (debug)
      cout << "Putting a line at:" << x1 << " " << y1 << " " << x2 << " " << y2
           << endl;
  }
};
int n;
map<int, int> mx, my;
vector<line> v;
int xm[2005], ym[2005];
int xc, yc;
bool wall[2005][2005], visit[2005][2005];
int dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};
void dfs(int x, int y) {
  if (x < 0 || x >= xc || y < 0 || y >= yc || wall[x][y] || visit[x][y]) return;
  visit[x][y] = true;
  for (int i = 0; i < 4; i++) {
    int nx = x + dx[i], ny = y + dy[i];
    dfs(nx, ny);
  }
}
int main(int argc, char* argv[]) {
  scanf("%d", &n);
  int x = 0, y = 0;
  for (int i = 0; i < n; i++) {
    char c;
    int d;
    cin >> c >> d;
    if (c == 'R') {
      line ln = line(x, y, x + d + 1, y + 1);
      v.push_back(ln);
      x += d;
    }
    if (c == 'L') {
      line ln = line(x - d, y, x + 1, y + 1);
      v.push_back(ln);
      x -= d;
    }
    if (c == 'U') {
      line ln = line(x, y, x + 1, y + d + 1);
      v.push_back(ln);
      y += d;
    }
    if (c == 'D') {
      line ln = line(x, y - d, x + 1, y + 1);
      v.push_back(ln);
      y -= d;
    }
  }
  for (int i = 0; i < v.size(); i++) {
    mx[v[i].x1] = 0;
    mx[v[i].x2] = 0;
    my[v[i].y1] = 0;
    my[v[i].y2] = 0;
  }
  for (map<int, int>::iterator it = mx.begin(); it != mx.end(); it++) {
    it->second = xc;
    xm[xc] = it->first;
    xc++;
  }
  for (map<int, int>::iterator it = my.begin(); it != my.end(); it++) {
    it->second = yc;
    ym[yc] = it->first;
    yc++;
  }
  xc--;
  yc--;
  for (int i = 0; i < v.size(); i++) {
    int x1 = mx[v[i].x1], x2 = mx[v[i].x2], y1 = my[v[i].y1], y2 = my[v[i].y2];
    for (int j = x1; j < x2; j++) {
      for (int k = y1; k < y2; k++) {
        wall[j][k] = true;
      }
    }
  }
  for (int i = 0; i < xc; i++) {
    for (int j = 0; j < yc; j++) {
      if (i == 0 || i == xc - 1 || j == 0 || j == yc - 1) {
        dfs(i, j);
      }
    }
  }
  long long ans = 0;
  for (int i = 0; i < xc; i++) {
    for (int j = 0; j < yc; j++) {
      if (!visit[i][j]) {
        long long a = xm[i + 1] - xm[i], b = ym[j + 1] - ym[j];
        ans += a * b;
      }
    }
  }
  cout << ans;
  return 0;
}
