#include <bits/stdc++.h>
using namespace std;
const int N = 1001;
map<int, int> MX, MY;
map<int, int>::iterator it;
int dx[4] = {-1, 0, 0, +1};
int dy[4] = {0, -1, +1, 0};
struct rect {
  int x1, y1, x2, y2;
};
rect A[N];
int VX[2 * N], VY[2 * N];
int X, Y;
int F[2 * N][2 * N];
void dfs(int x, int y) {
  if (x < 0 || y < 0 || x >= X || y >= Y || F[x][y]) return;
  F[x][y] = 2;
  for (int i = 0; i < 4; i++) dfs(x + dx[i], y + dy[i]);
}
int main() {
  int n;
  scanf("%d", &n);
  int x, y;
  x = y = 0;
  for (int i = 0; i < n; i++) {
    string s;
    int d;
    cin >> s >> d;
    if (s == "R") {
      A[i].x1 = x;
      A[i].y1 = y;
      A[i].x2 = x + d + 1;
      A[i].y2 = y + 1;
      x += d;
    } else if (s == "L") {
      A[i].x1 = x - d;
      A[i].y1 = y;
      A[i].x2 = x + 1;
      A[i].y2 = y + 1;
      x -= d;
    } else if (s == "U") {
      A[i].x1 = x;
      A[i].y1 = y;
      A[i].x2 = x + 1;
      A[i].y2 = y + d + 1;
      y += d;
    } else {
      A[i].x1 = x;
      A[i].y1 = y - d;
      A[i].x2 = x + 1;
      A[i].y2 = y + 1;
      y -= d;
    }
    MX[A[i].x1] = MX[A[i].x2] = 0;
    MY[A[i].y1] = MY[A[i].y2] = 0;
  }
  for (it = MX.begin(); it != MX.end(); it++) {
    it->second = X;
    VX[X] = it->first;
    X++;
  }
  for (it = MY.begin(); it != MY.end(); it++) {
    it->second = Y;
    VY[Y] = it->first;
    Y++;
  }
  X--;
  Y--;
  for (int i = 0; i < n; i++) {
    for (int j = MX[A[i].x1]; j < MX[A[i].x2]; j++)
      for (int k = MY[A[i].y1]; k < MY[A[i].y2]; k++) {
        F[j][k] = 1;
      }
  }
  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);
  long long int ans = 0;
  for (int i = 0; i < X; i++)
    for (int j = 0; j < Y; j++)
      if (F[i][j] != 2) {
        ans += (VX[i + 1] - VX[i]) * 1LL * (VY[j + 1] - VY[j]);
      }
  cout << ans << endl;
  return 0;
}
