#include <bits/stdc++.h>
using namespace std;
const int N = 6666;
map<int, int> xcmpr, ycmpr;
int xaxis[N], yaxis[N], xtot, ytot;
pair<int, int> pos[N];
queue<pair<int, int> > que;
int n, vis[N][N];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    char op[10];
    int d;
    scanf("%s%d", op, &d);
    pos[i] = pos[i - 1];
    switch (op[0]) {
      case 'R':
        pos[i].first += d;
        break;
      case 'L':
        pos[i].first -= d;
        break;
      case 'U':
        pos[i].second += d;
        break;
      case 'D':
        pos[i].second -= d;
        break;
    }
  }
  for (int i = 0; i <= n; ++i) {
    xcmpr[pos[i].first] = xcmpr[pos[i].first + 1] = xcmpr[pos[i].first - 1] = 1;
    ycmpr[pos[i].second] = ycmpr[pos[i].second + 1] = ycmpr[pos[i].second - 1] =
        1;
  }
  for (auto& t : xcmpr) xaxis[t.second = ++xtot] = t.first;
  for (auto& t : ycmpr) yaxis[t.second = ++ytot] = t.first;
  for (int i = 0; i <= n; ++i)
    pos[i].first = xcmpr[pos[i].first], pos[i].second = ycmpr[pos[i].second];
  for (int i = 0; i < n; ++i)
    for (int nx = min(pos[i].first, pos[i + 1].first),
             nxe = max(pos[i].first, pos[i + 1].first);
         nx <= nxe; ++nx)
      for (int ny = min(pos[i].second, pos[i + 1].second),
               nye = max(pos[i].second, pos[i + 1].second);
           ny <= nye; ++ny)
        vis[nx][ny] = 1;
  que.push(pair<int, int>(0, 0));
  while (!que.empty()) {
    pair<int, int> t = que.front();
    que.pop();
    const int dx[4] = {1, -1, 0, 0}, dy[4] = {0, 0, 1, -1};
    for (int d = 0; d < 4; ++d) {
      pair<int, int> nt = pair<int, int>(t.first + dx[d], t.second + dy[d]);
      if (nt.first >= 0 && nt.first <= xtot && nt.second >= 0 &&
          nt.second <= ytot)
        if (!vis[nt.first][nt.second]) {
          vis[nt.first][nt.second] = 2;
          que.push(nt);
        }
    }
  }
  long long res = 0;
  for (int i = 0; i <= xtot; ++i)
    for (int j = 0; j <= ytot; ++j)
      if (vis[i][j] != 2) {
        if (!i || i == xtot || !j || j == ytot) {
          if (vis[i][j] == 0)
            while (1)
              ;
          throw;
        }
        res += (long long)(xaxis[i + 1] - xaxis[i]) * (yaxis[j + 1] - yaxis[j]);
      }
  printf("%I64d\n", res);
  return 0;
}
