#include <bits/stdc++.h>
using namespace std;
const int NMax = 1100;
int N;
int LSH[NMax], nn, width[NMax * 2];
bool F[NMax * 2][NMax * 2], F1[NMax * 2][NMax * 2];
pair<int, int> pos[NMax];
map<int, int> ID, ID1, ID2;
int nn1;
long long ret;
void DFS(int first, int second) {
  if (first < 0 || second < 0 || first > nn1 + 1 || second > nn1 + 1 ||
      F[first][second] || F1[first][second])
    return;
  F1[first][second] = 1;
  ret -= (long long)width[first] * (long long)width[second];
  DFS(first - 1, second);
  DFS(first + 1, second);
  DFS(first, second - 1);
  DFS(first, second + 1);
}
int main() {
  scanf("%d", &N);
  nn = 0;
  int p = 0, q = 0;
  LSH[nn++] = 0;
  pos[0] = make_pair(0, 0);
  for (int i = 1; i <= N; i++) {
    char buf[5];
    int first;
    scanf("%s%d", buf, &first);
    if (buf[0] == 'U')
      q += first, LSH[nn++] = q;
    else if (buf[0] == 'D')
      q -= first, LSH[nn++] = q;
    else if (buf[0] == 'L')
      p -= first, LSH[nn++] = p;
    else
      p += first, LSH[nn++] = p;
    pos[i] = make_pair(p, q);
  }
  sort(LSH, LSH + nn);
  int last = -1000000001;
  int L = 0;
  for (int i = 0; i < nn; i++) {
    if (LSH[i] != last) {
      ID[LSH[i]] = ++L;
      ID1[L] = LSH[i];
      last = LSH[i];
    }
  }
  for (int i = 1; i <= L; i++) {
    if (i > 1 && ID1[i] > ID1[i - 1] + 1)
      width[++nn1] = ID1[i] - ID1[i - 1] - 1;
    width[++nn1] = 1;
    ID2[i] = nn1;
  }
  for (int i = 0; i <= N; i++) {
    pos[i].first = ID2[ID[pos[i].first]],
    pos[i].second = ID2[ID[pos[i].second]];
  }
  for (int i = 1; i <= N; i++) {
    if (pos[i].first == pos[i - 1].first) {
      for (int j = min(pos[i - 1].second, pos[i].second);
           j <= max(pos[i - 1].second, pos[i].second); j++)
        F[pos[i].first][j] = 1;
    } else {
      for (int j = min(pos[i - 1].first, pos[i].first);
           j <= max(pos[i - 1].first, pos[i].first); j++)
        F[j][pos[i].second] = 1;
    }
  }
  ret = (long long)(ID1[L] - ID1[1] + 1) * (long long)(ID1[L] - ID1[1] + 1);
  DFS(0, 0);
  printf("%I64d\n", ret);
  getchar();
  getchar();
  return 0;
}
