#include <bits/stdc++.h>
using namespace std;
const int maxn = 1010;
int n;
int g[maxn * 2][maxn * 2], tot;
int d[maxn];
int R, C;
char c[maxn];
vector<int> x, y, col, row;
int find(vector<int>& x, int y) {
  return lower_bound(x.begin(), x.end(), y) - x.begin();
}
char check(int x, int y) {
  return x >= 0 && x < R && y >= 0 && y < C && g[x][y] < tot;
}
int dir[][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
void dfs(int x, int y) {
  if (check(x, y) == 0) return;
  g[x][y] = tot + 1;
  for (int i = 0; i < 4; i++) {
    int nx = x + dir[i][0], ny = y + dir[i][1];
    dfs(nx, ny);
  }
}
int main() {
  while (~scanf("%d", &n)) {
    tot++;
    for (int i = 0; i < n; i++) {
      char s[3];
      scanf("%s%d", s, d + i);
      c[i] = s[0];
    }
    x.clear(), y.clear(), col.clear(), row.clear();
    int nx = 0, ny = 0;
    x.push_back(nx);
    y.push_back(ny);
    for (int i = 0; i < n; i++) {
      if (c[i] == 'R')
        ny += d[i];
      else if (c[i] == 'L')
        ny -= d[i];
      else if (c[i] == 'U')
        nx -= d[i];
      else
        nx += d[i];
      x.push_back(nx);
      y.push_back(ny);
    }
    sort(x.begin(), x.end());
    int s = unique(x.begin(), x.end()) - x.begin();
    x.erase(x.begin() + s, x.end());
    sort(y.begin(), y.end());
    s = unique(y.begin(), y.end()) - y.begin();
    y.erase(y.begin() + s, y.end());
    row.push_back(1);
    for (int i = 1, j = x.size(); i < j; i++) {
      if (x[i - 1] + 1 < x[i])
        row.push_back(x[i] - x[i - 1] - 1), x.push_back(x[i] - 1);
      row.push_back(1);
    }
    sort(x.begin(), x.end());
    col.push_back(1);
    for (int i = 1, j = y.size(); i < j; i++) {
      if (y[i - 1] + 1 < y[i])
        col.push_back(y[i] - y[i - 1] - 1), y.push_back(y[i] - 1);
      col.push_back(1);
    }
    sort(y.begin(), y.end());
    R = x.size(), C = y.size();
    nx = 0, ny = 0;
    int nxx = find(x, nx), nyy = find(y, ny);
    for (int i = 0; i < n; i++) {
      if (c[i] == 'R')
        ny += d[i];
      else if (c[i] == 'L')
        ny -= d[i];
      else if (c[i] == 'U')
        nx -= d[i];
      else
        nx += d[i];
      int tx = find(x, nx), ty = find(y, ny);
      if (tx < nxx) swap(tx, nxx);
      if (ty < nyy) swap(ty, nyy);
      for (int k = nxx; k <= tx; k++)
        for (int l = nyy; l <= ty; l++) g[k][l] = tot;
      nxx = find(x, nx), nyy = find(y, ny);
    }
    for (int i = 0; i < R; i++) dfs(i, 0), dfs(i, C - 1);
    for (int j = 0; j < C; j++) dfs(0, j), dfs(R - 1, j);
    tot++;
    unsigned long long ans = 0;
    for (int i = 0; i < R; i++)
      for (int j = 0; j < C; j++)
        if (g[i][j] < tot) ans += (unsigned long long)row[i] * col[j];
    cout << ans << endl;
  }
  return 0;
}
