#include <bits/stdc++.h>
using namespace std;
map<int, int> Hash;
struct rec {
  int x0, x1, y0, y1;
  void role() {
    if (x0 > x1) swap(x0, x1);
    if (y0 > y1) swap(y0, y1);
  }
} E[23333];
int nx, ny, num, tot;
int g[23333], valx[23333], valy[23333];
int dx[8] = {0, 1, -1, 0, 0};
int dy[8] = {0, 0, 0, 1, -1};
bool wall[4333][4333], infect[4333][4333];
long long ans;
char ch[8];
void init() {
  int n, d;
  scanf("%d", &n);
  nx = ny = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%s%d", ch, &d);
    ++tot;
    E[tot].x0 = nx;
    E[tot].y0 = ny;
    if (ch[0] == 'R') nx += d;
    if (ch[0] == 'L') nx -= d;
    if (ch[0] == 'U') ny += d;
    if (ch[0] == 'D') ny -= d;
    E[tot].x1 = nx;
    E[tot].y1 = ny;
    E[tot].role();
  }
  nx = ny = 0;
  num = 0;
  for (int i = 1; i <= tot; i++) {
    g[++num] = E[i].x0;
    g[++num] = E[i].x1;
  }
  sort(g + 1, g + 1 + num);
  for (int i = 1, j = 1; i <= num; i = j) {
    Hash[g[i]] = ++nx;
    valx[nx] = 1;
    for (j = i; g[i] == g[j] && j <= num; j++)
      ;
    if (g[i] + 1 < g[j] && j <= num) valx[++nx] = g[j] - g[i] - 1;
  }
  for (int i = 1; i <= tot; i++) {
    E[i].x0 = Hash[E[i].x0];
    E[i].x1 = Hash[E[i].x1];
  }
  num = 0;
  for (int i = 1; i <= tot; i++) {
    g[++num] = E[i].y0;
    g[++num] = E[i].y1;
  }
  sort(g + 1, g + 1 + num);
  for (int i = 1, j = 1; i <= num; i = j) {
    Hash[g[i]] = ++ny;
    valy[ny] = 1;
    for (j = i; g[i] == g[j] && j <= num; j++)
      ;
    if (g[i] + 1 < g[j] && j <= num) valy[++ny] = g[j] - g[i] - 1;
  }
  for (int i = 1; i <= tot; i++) {
    E[i].y0 = Hash[E[i].y0];
    E[i].y1 = Hash[E[i].y1];
  }
  for (int i = 1; i <= tot; i++)
    for (int j = E[i].x0; j <= E[i].x1; j++)
      for (int k = E[i].y0; k <= E[i].y1; k++) wall[j][k] = 1;
}
void virus(int x, int y) {
  infect[x][y] = 1;
  for (int i = 1; i <= 4; i++) {
    int xx = x + dx[i], yy = y + dy[i];
    if (xx < 1 || xx > nx || yy < 1 || yy > ny) continue;
    if (wall[xx][yy] || infect[xx][yy]) continue;
    virus(xx, yy);
  }
}
void work() {
  for (int i = 1; i <= nx; i++)
    for (int j = 1; j <= ny; j++)
      if (i == 1 || i == nx || j == 1 || j == ny)
        if (!infect[i][j] && !wall[i][j]) virus(i, j);
  for (int i = 1; i <= nx; i++)
    for (int j = 1; j <= ny; j++)
      if (!infect[i][j]) ans += 1LL * valx[i] * valy[j];
  printf("%I64d\n", ans);
}
int main() {
  init();
  work();
}
