#include <bits/stdc++.h>
using namespace std;
const int NN = 3005;
int n, lx, ly, X[NN], Y[NN], lsx[NN], lsy[NN], a[NN][NN];
long long ans;
void addx(int x) {
  lsx[++lsx[0]] = x - 1;
  lsx[++lsx[0]] = x;
  lsx[++lsx[0]] = x + 1;
}
void addy(int y) {
  lsy[++lsy[0]] = y - 1;
  lsy[++lsy[0]] = y;
  lsy[++lsy[0]] = y + 1;
}
char get() {
  char ch = getchar();
  while (ch < 'A' || ch > 'Z') ch = getchar();
  return ch;
}
void work(int *ls, int &len) {
  len = 1;
  for (int i = (2); i <= (ls[0]); i++)
    if (ls[i] > ls[i - 1]) ls[++len] = ls[i];
}
void dfs(int x, int y) {
  if (x < 0 || x > lx + 1 || y < 0 || y > ly + 1 || a[x][y]) return;
  a[x][y] = -1;
  dfs(x - 1, y);
  dfs(x + 1, y);
  dfs(x, y - 1);
  dfs(x, y + 1);
}
int findx(int x) {
  for (int L = 1, R = lx, mid; L <= R;) {
    mid = (L + R) >> 1;
    if (x == lsx[mid]) return mid;
    if (x < lsx[mid])
      R = mid - 1;
    else
      L = mid + 1;
  }
}
int findy(int y) {
  for (int L = 1, R = ly, mid; L <= R;) {
    mid = (L + R) >> 1;
    if (y == lsy[mid]) return mid;
    if (y < lsy[mid])
      R = mid - 1;
    else
      L = mid + 1;
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1, c, x; i <= n; i++) {
    c = get();
    scanf("%d", &x);
    X[i] = X[i - 1];
    Y[i] = Y[i - 1];
    if (c == 'L') Y[i] -= x;
    if (c == 'R') Y[i] += x;
    if (c == 'U') X[i] -= x;
    if (c == 'D') X[i] += x;
  }
  for (int i = (0); i <= (n); i++) addx(X[i]), addy(Y[i]);
  sort(lsx + 1, lsx + lsx[0] + 1);
  work(lsx, lx);
  for (int i = (0); i <= (n); i++) X[i] = findx(X[i]);
  sort(lsy + 1, lsy + lsy[0] + 1);
  work(lsy, ly);
  for (int i = (0); i <= (n); i++) Y[i] = findy(Y[i]);
  for (int i = (1); i <= (n); i++)
    if (X[i] == X[i - 1])
      for (int j = (min(Y[i], Y[i - 1])); j <= (max(Y[i], Y[i - 1])); j++)
        a[X[i]][j] = 1;
    else
      for (int j = (min(X[i], X[i - 1])); j <= (max(X[i], X[i - 1])); j++)
        a[j][Y[i]] = 1;
  dfs(0, 0);
  for (int i = (1); i <= (lx); i++)
    for (int j = (1); j <= (ly); j++)
      if (a[i][j] >= 0)
        ans += 1LL * (lsx[i] - lsx[i - 1]) * (lsy[j] - lsy[j - 1]);
  printf("%I64d\n", ans);
  return 0;
}
