#include <bits/stdc++.h>
using namespace std;
const int N = 3000;
short int f[N + 3][N + 3], qx[8000000 + 3], qy[8000000 + 3], qX[1000 + 3],
    qY[1000 + 3];
class Dot {
 public:
  int x, xx;
} Qx[1000 + 3], Qy[1000 + 3];
int Larx[N + 3], Lary[N + 3], n, Xn, Yn, X, Y;
long long ans;
char ss[3];
const int tx[4] = {1, -1, 0, 0};
const int ty[4] = {0, 0, 1, -1};
bool comp(const Dot &A, const Dot &B) { return A.x < B.x; }
int main() {
  scanf("%d", &n);
  X = 0, Y = 0;
  ++Xn, ++Yn;
  for (int i = 1; i <= n; i++) {
    int l;
    scanf("%s%d", ss + 1, &l);
    if (ss[1] == 'R') Y += l;
    if (ss[1] == 'L') Y -= l;
    if (ss[1] == 'U') X -= l;
    if (ss[1] == 'D') X += l;
    Qx[++Xn].x = X;
    Qx[Xn].xx = i;
    Qy[++Yn].x = Y;
    Qy[Yn].xx = i;
  }
  sort(Qx + 1, Qx + Xn + 1, comp);
  sort(Qy + 1, Qy + Yn + 1, comp);
  int tmp = 1;
  Larx[1] = 1;
  Qx[0].x = Qx[1].x - 1;
  for (int i = 1; i <= Xn; i++) {
    if (Qx[i].x != Qx[i - 1].x) {
      tmp++;
      if (Qx[i].x - Qx[i - 1].x > 1) {
        Larx[tmp++] = Qx[i].x - Qx[i - 1].x - 1;
      }
      Larx[tmp] = 1;
    }
    qX[Qx[i].xx] = tmp;
  }
  Larx[++tmp] = 1;
  Xn = tmp;
  tmp = 1;
  Lary[1] = 1;
  Qy[0].x = Qy[1].x - 1;
  for (int i = 1; i <= Yn; i++) {
    if (Qy[i].x != Qy[i - 1].x) {
      tmp++;
      if (Qy[i].x - Qy[i - 1].x > 1) {
        Lary[tmp++] = Qy[i].x - Qy[i - 1].x - 1;
      }
      Lary[tmp] = 1;
    }
    qY[Qy[i].xx] = tmp;
  }
  Lary[++tmp] = 1;
  Yn = tmp;
  for (int i = 1; i <= n; i++) {
    int lx = min(qX[i - 1], qX[i]), rx = max(qX[i - 1], qX[i]);
    int ly = min(qY[i - 1], qY[i]), ry = max(qY[i - 1], qY[i]);
    for (int j = lx; j <= rx; j++)
      for (int k = ly; k <= ry; k++) f[j][k] = 2;
  }
  qx[1] = 1, qy[1] = 1;
  f[1][1] = 1;
  for (int l = 0, r = 1; l < r;) {
    int x = qx[++l], y = qy[l];
    for (int i = 0; i < 4; i++) {
      int x3 = x + tx[i], y3 = y + ty[i];
      if (x3 < 1 || x3 > Xn || y3 < 1 || y3 > Yn) continue;
      if (f[x3][y3]) continue;
      qx[++r] = x3, qy[r] = y3;
      f[x3][y3] = 1;
    }
  }
  for (int i = 1; i <= Xn; i++)
    for (int j = 1; j <= Yn; j++)
      if (f[i][j] != 1) ans += (long long)(Larx[i]) * Lary[j];
  printf("%I64d", ans);
}
