#include <bits/stdc++.h>
using namespace std;
struct rect {
  int x1, y1, x2, y2;
  rect(int a, int b, int c, int d) {
    x1 = a;
    y1 = b;
    x2 = c;
    y2 = d;
  }
};
int n, max_x, max_y, xm[2005], ym[2005], dx[4] = {1, -1, 0, 0},
                                         dy[4] = {0, 0, 1, -1};
long long ans;
bool field[2005][2005], area[2005][2005];
vector<rect> R;
map<int, int> mx, my;
void dfs(int x, int y) {
  if (x < 0 || x >= max_x || y < 0 || y >= max_y || field[x][y] || area[x][y])
    return;
  area[x][y] = 1;
  for (int i = 0; i < 4; i++) {
    dfs(x + dx[i], y + dy[i]);
  }
}
int main() {
  cin >> n;
  int x = 0, y = 0;
  for (int i = 0; i < n; i++) {
    char dir;
    int d, dx, dy;
    cin >> dir >> d;
    dx = (dir == 'R') - (dir == 'L');
    dy = (dir == 'U') - (dir == 'D');
    R.push_back(rect(x - (dir == 'L') * d, y - (dir == 'D') * d,
                     x + 1 + (dir == 'R') * d, y + 1 + (dir == 'U') * d));
    x += dx * d;
    y += dy * d;
  }
  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 (__typeof(mx.begin()) i = mx.begin(); i != mx.end(); i++) {
    i->second = max_x;
    xm[max_x] = i->first;
    max_x++;
  }
  for (__typeof(my.begin()) i = my.begin(); i != my.end(); i++) {
    i->second = max_y;
    ym[max_y] = i->first;
    max_y++;
  }
  max_x--;
  max_y--;
  for (int i = 0; i < n; i++) {
    int x1 = mx[R[i].x1], x2 = mx[R[i].x2], y1 = my[R[i].y1], y2 = my[R[i].y2];
    for (int j = x1; j < x2; j++) {
      for (int k = y1; k < y2; k++) {
        field[j][k] = 1;
      }
    }
  }
  for (int i = 0; i < max_x; i++) {
    for (int j = 0; j < max_y; j++) {
      if (i == 0 || i == max_x - 1 || j == 0 || j == max_y - 1) {
        dfs(i, j);
      }
    }
  }
  for (int i = 0; i < max_x; i++) {
    for (int j = 0; j < max_y; j++) {
      if (!area[i][j]) {
        long long dx = xm[i + 1] - xm[i], dy = ym[j + 1] - ym[j];
        ans += dx * dy;
      }
    }
  }
  cout << ans << endl;
}
