#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int dirx[] = {1, -1, 0, 0};
const int diry[] = {0, 0, 1, -1};
int n, i, j, k, vis[6005][6005];
pair<int, int> a[1005];
char s[15];
vector<int> dx, dy;
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    int x;
    scanf("%s%d", s, &x);
    int newx = a[i - 1].first;
    int newy = a[i - 1].second;
    if (s[0] == 'U') newx -= x;
    if (s[0] == 'D') newx += x;
    if (s[0] == 'L') newy -= x;
    if (s[0] == 'R') newy += x;
    a[i] = {newx, newy};
    dx.push_back(newx);
    dx.push_back(newx - 1);
    dx.push_back(newx + 1);
    dy.push_back(newy);
    dy.push_back(newy - 1);
    dy.push_back(newy + 1);
  }
  dx.push_back(0);
  dx.push_back(-1);
  dx.push_back(1);
  dy.push_back(0);
  dy.push_back(-1);
  dy.push_back(1);
  dx.push_back(-INF);
  dy.push_back(-INF);
  sort(dx.begin(), dx.end());
  sort(dy.begin(), dy.end());
  dx.resize(unique(dx.begin(), dx.end()) - dx.begin());
  dy.resize(unique(dy.begin(), dy.end()) - dy.begin());
  for (i = 0; i <= n; i++) {
    a[i].first = lower_bound(dx.begin(), dx.end(), a[i].first) - dx.begin();
    a[i].second = lower_bound(dy.begin(), dy.end(), a[i].second) - dy.begin();
  }
  for (i = 0; i < n; i++) {
    int sx = min(a[i].first, a[i + 1].first);
    int sy = min(a[i].second, a[i + 1].second);
    int tx = max(a[i].first, a[i + 1].first);
    int ty = max(a[i].second, a[i + 1].second);
    for (j = sx; j <= tx; j++) {
      for (k = sy; k <= ty; k++) vis[j][k] = 1;
    }
  }
  queue<pair<int, int> > b;
  vis[0][0] = 2;
  b.push({0, 0});
  while (b.size()) {
    pair<int, int> now = b.front();
    b.pop();
    for (i = 0; i < 4; i++) {
      int newx = now.first + dirx[i];
      int newy = now.second + diry[i];
      if (newx >= 0 && newx < dx.size() && newy >= 0 && newy < dy.size() &&
          vis[newx][newy] == 0) {
        vis[newx][newy] = 2;
        b.push({newx, newy});
      }
    }
  }
  long long res = 0;
  for (i = 0; i < dx.size(); i++) {
    for (j = 0; j < dy.size(); j++) {
      if (vis[i][j] == 0 || vis[i][j] == 1) {
        int w, h;
        w = dx[i + 1] - dx[i];
        h = dy[j + 1] - dy[j];
        res += (long long)h * w;
      }
    }
  }
  printf("%lld\n", res);
}
