#include <bits/stdc++.h>
using namespace std;
map<int, int> mx, my;
int xm[2010], ym[2010];
int a[2010][2010], obs[2010][2010];
int dir[4][2] = {0, 1, 0, -1, 1, 0, -1, 0};
struct rec {
  int x1, y1, x2, y2;
  rec(int a = 0, int b = 0, int c = 0, int d = 0) {
    x1 = a;
    y1 = b;
    x2 = c;
    y2 = d;
  }
};
vector<rec> r;
int X, Y;
int n;
void dfs(int x, int y) {
  if (x < 0 || x >= X || y < 0 || y >= Y || a[x][y] || obs[x][y]) return;
  a[x][y] = 1;
  for (int i = 0; i < 4; i++) {
    int xx = x + dir[i][0], yy = y + dir[i][1];
    dfs(xx, yy);
  }
}
void read() {
  int x = 0, y = 0;
  int d;
  char ch;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> ch >> d;
    if (ch == 'L') {
      r.push_back(rec(x - d, y, x + 1, y + 1));
      x -= d;
    } else if (ch == 'R') {
      r.push_back(rec(x, y, x + d + 1, y + 1));
      x += d;
    } else if (ch == 'U') {
      r.push_back(rec(x, y, x + 1, y + d + 1));
      y += d;
    } else if (ch == 'D') {
      r.push_back(rec(x, y - d, x + 1, y + 1));
      y -= d;
    }
  }
}
void lisan() {
  for (int i = 0; i < n; i++) {
    mx[r[i].x1] = mx[r[i].x2] = 0;
    my[r[i].y1] = my[r[i].y2] = 0;
  }
  for (map<int, int>::iterator it = mx.begin(); it != mx.end(); it++) {
    it->second = X;
    xm[X] = it->first;
    X++;
  }
  for (map<int, int>::iterator it = my.begin(); it != my.end(); it++) {
    it->second = Y;
    ym[Y] = it->first;
    Y++;
  }
  X--;
  Y--;
}
void gset() {
  for (int i = 0; i < n; i++) {
    int x1 = mx[r[i].x1], y1 = my[r[i].y1], x2 = mx[r[i].x2], y2 = my[r[i].y2];
    for (int p = x1; p < x2; p++) {
      for (int q = y1; q < y2; q++) {
        obs[p][q] = 1;
      }
    }
  }
}
void floodfill() {
  for (int i = 0; i < X; i++) {
    for (int j = 0; j < Y; j++) {
      if (i == 0 || i == X - 1 || j == 0 || j == Y - 1) {
        dfs(i, j);
      }
    }
  }
}
void output() {
  long long res = 0;
  for (int i = 0; i < X; i++) {
    for (int j = 0; j < Y; j++) {
      if (!a[i][j]) {
        long long dx = xm[i + 1] - xm[i], dy = ym[j + 1] - ym[j];
        res += dx * dy;
      }
    }
  }
  cout << res << '\n';
}
int main() {
  ios::sync_with_stdio(0);
  read();
  lisan();
  gset();
  floodfill();
  output();
  return 0;
}
