#include <bits/stdc++.h>
using namespace std;
queue<pair<int, int> > q;
set<int> lcoord, ccoord;
set<int>::iterator it;
vector<pair<pair<int, int>, pair<int, int> > > moves;
vector<int> lco, cco;
int N, i, l, c, ll, cc, dist;
char dir;
char A[3100][3100];
long long answer;
void Expand(int row, int col) {
  A[row][col] = 2;
  q.push(make_pair(row, col));
  while (q.size() > 0) {
    pair<int, int> pp = q.front();
    q.pop();
    if (pp.first - 1 >= 0 && A[pp.first - 1][pp.second] == 0) {
      A[pp.first - 1][pp.second] = 2;
      q.push(make_pair(pp.first - 1, pp.second));
    }
    if (pp.first + 1 <= lco.size() - 2 && A[pp.first + 1][pp.second] == 0) {
      A[pp.first + 1][pp.second] = 2;
      q.push(make_pair(pp.first + 1, pp.second));
    }
    if (pp.second - 1 >= 0 && A[pp.first][pp.second - 1] == 0) {
      A[pp.first][pp.second - 1] = 2;
      q.push(make_pair(pp.first, pp.second - 1));
    }
    if (pp.second + 1 <= cco.size() - 2 && A[pp.first][pp.second + 1] == 0) {
      A[pp.first][pp.second + 1] = 2;
      q.push(make_pair(pp.first, pp.second + 1));
    }
  }
}
int main() {
  scanf("%d", &N);
  l = c = 0;
  lcoord.insert(l);
  lcoord.insert(l - 1);
  lcoord.insert(l + 1);
  ccoord.insert(c);
  ccoord.insert(c - 1);
  ccoord.insert(c + 1);
  for (i = 1; i <= N; i++) {
    scanf(" %c %d", &dir, &dist);
    if (dir == 'U') {
      ll = l - dist;
      cc = c;
    } else if (dir == 'R') {
      ll = l;
      cc = c + dist;
    } else if (dir == 'D') {
      ll = l + dist;
      cc = c;
    } else if (dir == 'L') {
      ll = l;
      cc = c - dist;
    }
    lcoord.insert(ll);
    lcoord.insert(ll - 1);
    lcoord.insert(ll + 1);
    ccoord.insert(cc);
    ccoord.insert(cc - 1);
    ccoord.insert(cc + 1);
    moves.push_back(make_pair(make_pair(l, c), make_pair(ll, cc)));
    l = ll;
    c = cc;
  }
  lcoord.insert(-2000000000);
  lcoord.insert(+2000000000);
  ccoord.insert(-2000000000);
  ccoord.insert(+2000000000);
  for (it = lcoord.begin(); it != lcoord.end(); it++) {
    lco.push_back(*it);
  }
  for (it = ccoord.begin(); it != ccoord.end(); it++) {
    cco.push_back(*it);
  }
  for (i = 0; i < moves.size(); i++) {
    int lmin, cmin, lmax, cmax;
    lmin = min(moves[i].first.first, moves[i].second.first);
    lmax = max(moves[i].first.first, moves[i].second.first);
    cmin = min(moves[i].first.second, moves[i].second.second);
    cmax = max(moves[i].first.second, moves[i].second.second);
    for (l = 0; l < lco.size(); l++)
      if (lco[l] == lmin) break;
    for (c = 0; c < cco.size(); c++)
      if (cco[c] == cmin) break;
    for (ll = l; ll < lco.size() && lco[ll] <= lmax; ll++)
      for (cc = c; cc < cco.size() && cco[cc] <= cmax; cc++) A[ll][cc] = 1;
  }
  for (l = 0; l <= lco.size() - 2; l++) {
    if (A[l][0] == 0) Expand(l, 0);
    if (A[l][cco.size() - 2] == 0) Expand(l, cco.size() - 2);
  }
  for (c = 0; c <= cco.size() - 2; c++) {
    if (A[0][c] == 0) Expand(0, c);
    if (A[lco.size() - 2][c] == 0) Expand(lco.size() - 2, c);
  }
  answer = 0;
  for (l = 0; l <= lco.size() - 2; l++)
    for (c = 0; c <= cco.size() - 2; c++) {
      if (A[l][c] != 2) {
        answer += ((long long)lco[l + 1] - (long long)lco[l]) *
                  ((long long)cco[c + 1] - (long long)cco[c]);
      }
    }
  printf("%I64d\n", answer);
  return 0;
}
