#include <bits/stdc++.h>
using namespace std;
const int maxn = 3006, maxm = 200008;
struct Tedge {
  int start[maxn], tot;
  struct arr {
    int a, next;
  } e[maxm];
  void clear() {
    tot = 1;
    memset(start, 0, sizeof(start));
  }
  void add(int x, int y) {
    e[++tot].a = y;
    e[tot].next = start[x];
    start[x] = tot;
    e[++tot].a = x;
    e[tot].next = start[y];
    start[y] = tot;
  }
} E;
const int Dy[6] = {0, 0, 0, 1, -1};
const int Dx[6] = {0, 1, -1, 0, 0};
int n, kx, ky, x[maxn], y[maxn];
int lisanx[maxn], lisany[maxn], q[maxn * maxn][2];
bool flag[maxn][maxn], in[maxn][maxn];
char tmp[maxn][10];
struct Tprogram {
  void open() {}
  void close() {}
  void init() {
    int nx, ny, d;
    scanf("%d", &n);
    nx = ny = 0;
    lisanx[++kx] = 0;
    lisany[++ky] = 0;
    lisanx[++kx] = 1;
    lisany[++ky] = 1;
    for (int i = 1; i <= n; i++) {
      scanf("%s%d", tmp[i], &d);
      if (tmp[i][0] == 'R') nx += d;
      if (tmp[i][0] == 'L') nx -= d;
      if (tmp[i][0] == 'U') ny += d;
      if (tmp[i][0] == 'D') ny -= d;
      lisanx[++kx] = nx;
      lisany[++ky] = ny;
      lisanx[++kx] = nx + 1;
      lisany[++ky] = ny + 1;
      x[i] = nx;
      y[i] = ny;
    }
    sort(lisanx + 1, lisanx + 1 + kx);
    kx = unique(lisanx + 1, lisanx + 1 + kx) - lisanx - 1;
    sort(lisany + 1, lisany + 1 + ky);
    ky = unique(lisany + 1, lisany + 1 + ky) - lisany - 1;
    for (int i = 0; i <= n; i++) {
      x[i] = lower_bound(lisanx + 1, lisanx + 1 + kx, x[i]) - lisanx;
      y[i] = lower_bound(lisany + 1, lisany + 1 + ky, y[i]) - lisany;
    }
  }
  void work1() {
    int l = 0, r = 0;
    for (int i = 1; i <= kx; i++) {
      q[++r][0] = i;
      q[r][1] = 0;
      in[i][0] = 1;
      q[++r][0] = i;
      q[r][1] = ky + 1;
      in[i][ky + 1] = 1;
    }
    for (int i = 1; i <= ky; i++) {
      q[++r][0] = 0;
      q[r][1] = i;
      in[0][i] = 1;
      q[++r][0] = kx + 1;
      q[r][1] = i;
      in[kx + 1][i] = 1;
    }
    while (l != r) {
      int x, y, xx, yy;
      ++l;
      x = q[l][0];
      y = q[l][1];
      for (int i = 1; i <= 4; i++) {
        xx = x + Dx[i];
        yy = y + Dy[i];
        if (xx < 0 || xx > kx + 1 || yy < 0 || yy > ky + 1 || in[xx][yy] ||
            flag[xx][yy])
          continue;
        q[++r][0] = xx;
        q[r][1] = yy;
        in[xx][yy] = 1;
      }
    }
  }
  void work() {
    int nx, ny, dx, dy;
    nx = x[0];
    ny = y[0];
    flag[nx][ny] = 1;
    for (int i = 1; i <= n; i++) {
      if (tmp[i][0] == 'U') dx = 0, dy = 1;
      if (tmp[i][0] == 'D') dx = 0, dy = -1;
      if (tmp[i][0] == 'R') dx = 1, dy = 0;
      if (tmp[i][0] == 'L') dx = -1, dy = 0;
      while (nx != x[i] || ny != y[i]) {
        nx += dx;
        ny += dy;
        flag[nx][ny] = 1;
      }
    }
    work1();
    long long ans = 0;
    for (int i = 1; i <= kx; i++)
      for (int j = 1; j <= ky; j++)
        if (!in[i][j]) {
          ans += (long long)(lisanx[i + 1] - lisanx[i]) *
                 (lisany[j + 1] - lisany[j]);
        }
    printf("%I64d\n", ans);
  }
} Program;
int main() {
  Program.open();
  Program.init();
  Program.work();
  Program.close();
  return 0;
}
