#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007, dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
const double eps = 1e-8;
void read(int &k) {
  k = 0;
  char x = getchar();
  while (x < '0' || x > '9') x = getchar();
  while (x >= '0' && x <= '9') {
    k = k * 10 - 48 + x;
    x = getchar();
  }
}
int n, tra[128], lx, ly, Lx[10010], Ly[10010], a[2100][2100], ll, rr, tx, ty,
    nx, ny, k;
pair<pair<int, int>, pair<int, int> > ope[1010];
pair<int, int> dd[5000000];
char s[10];
void update(int type, int &x) {
  if (!type)
    x = lower_bound(Lx + 1, Lx + lx + 1, x) - Lx;
  else
    x = lower_bound(Ly + 1, Ly + ly + 1, x) - Ly;
}
int main() {
  tra['R'] = 0;
  tra['D'] = 1;
  tra['L'] = 2;
  tra['U'] = 3;
  scanf("%d", &n);
  nx = 0;
  ny = 0;
  Lx[++lx] = 0;
  Ly[++ly] = 0;
  Ly[++ly] = Lx[++lx] = 1000000003;
  Ly[++ly] = Lx[++lx] = -1000000003;
  Lx[++lx] = 1;
  Ly[++ly] = 1;
  for (int i = 1; i <= n; i++) {
    scanf("%s%d", s, &k);
    ope[i].first = make_pair(nx, ny);
    nx += dx[tra[s[0]]] * k;
    ny += dy[tra[s[0]]] * k;
    ope[i].second = make_pair(nx, ny);
    Lx[++lx] = nx;
    Ly[++ly] = ny;
    Lx[++lx] = nx + 1;
    Ly[++ly] = ny + 1;
  }
  sort(Lx + 1, Lx + lx + 1);
  lx = unique(Lx + 1, Lx + lx + 1) - Lx - 1;
  sort(Ly + 1, Ly + ly + 1);
  ly = unique(Ly + 1, Ly + ly + 1) - Ly - 1;
  for (int i = 1; i <= n; i++) {
    update(0, ope[i].first.first);
    update(1, ope[i].first.second);
    update(0, ope[i].second.first);
    update(1, ope[i].second.second);
    if (ope[i].first.first == ope[i].second.first) {
      if (ope[i].first.second > ope[i].second.second)
        swap(ope[i].first.second, ope[i].second.second);
      for (int j = ope[i].first.second; j <= ope[i].second.second; j++)
        a[ope[i].first.first][j] = 1;
    } else {
      if (ope[i].first.first > ope[i].second.first)
        swap(ope[i].first.first, ope[i].second.first);
      for (int j = ope[i].first.first; j <= ope[i].second.first; j++)
        a[j][ope[i].first.second] = 1;
    }
  }
  a[1][1] = 2;
  for (dd[ll = rr = 0] = make_pair(1, 1); ll <= rr; ll++) {
    for (int dir = 0; dir < 4; dir++) {
      tx = dd[ll].first + dx[dir];
      ty = dd[ll].second + dy[dir];
      if (tx > 0 && tx <= lx && ty > 0 && ty <= ly && !a[tx][ty])
        a[tx][ty] = 2, dd[++rr] = make_pair(tx, ty);
    }
  }
  long long ans = 0;
  for (int i = 1; i <= lx; i++)
    for (int j = 1; j <= ly; j++)
      if (a[i][j] <= 1) ans += 1ll * (Lx[i + 1] - Lx[i]) * (Ly[j + 1] - Ly[j]);
  cout << ans << endl;
  return 0;
}
