#include <bits/stdc++.h>
using namespace std;
int n, m, T;
char s[3];
long long x;
int now[2], last[2];
long long ans;
struct node {
  int p1, q1, p2, q2;
};
struct edge {
  int x, y;
  edge() {}
  edge(int X, int Y) {
    x = X;
    y = Y;
  }
};
vector<long long> X;
vector<long long> Y;
node a[1003];
int vis[2003][2003];
queue<edge> q;
int dis[5][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
int main() {
  X.push_back(-0x7f7f7f7f);
  X.push_back(0x7f7f7f7f);
  Y.push_back(-0x7f7f7f7f);
  Y.push_back(0x7f7f7f7f);
  scanf("%d", &T);
  for (int i = 1; i <= T; i++) {
    scanf("%s", s);
    scanf("%lld", &x);
    if (s[0] == 'R') {
      now[0] = last[0];
      now[1] = last[1] + x;
    } else if (s[0] == 'L') {
      now[0] = last[0];
      now[1] = last[1] - x;
    } else if (s[0] == 'U') {
      now[0] = last[0] - x;
      now[1] = last[1];
    } else {
      now[0] = last[0] + x;
      now[1] = last[1];
    }
    X.push_back(min(now[0], last[0])), X.push_back(max(now[0], last[0]) + 1);
    Y.push_back(min(now[1], last[1])), Y.push_back(max(now[1], last[1]) + 1);
    a[i].p1 = min(now[0], last[0]), a[i].p2 = max(now[0], last[0]) + 1;
    a[i].q1 = min(now[1], last[1]), a[i].q2 = max(now[1], last[1]) + 1;
    last[0] = now[0], last[1] = now[1];
  }
  sort(X.begin(), X.end());
  sort(Y.begin(), Y.end());
  n = unique(X.begin(), X.end()) - X.begin(),
  m = unique(Y.begin(), Y.end()) - Y.begin();
  n = X.size(), m = Y.size();
  for (int i = 1; i <= T; i++) {
    last[0] = find(X.begin(), X.end(), a[i].p1) - X.begin(),
    now[0] = find(X.begin(), X.end(), a[i].p2) - X.begin() - 1;
    last[1] = find(Y.begin(), Y.end(), a[i].q1) - Y.begin(),
    now[1] = find(Y.begin(), Y.end(), a[i].q2) - Y.begin() - 1;
    for (int j = last[0]; j <= now[0]; j++)
      for (int k = last[1]; k <= now[1]; k++) vis[j][k] = 1;
  }
  q.push(edge(0, 0));
  vis[0][0] = 2;
  while (!q.empty()) {
    edge tx = q.front();
    q.pop();
    for (int i = 0; i < 4; i++) {
      edge nx = tx;
      nx.x += dis[i][0];
      nx.y += dis[i][1];
      if (nx.x >= 0 && nx.y >= 0 && nx.x < n && nx.y < m &&
          vis[nx.x][nx.y] == 0) {
        vis[nx.x][nx.y] = 2;
        q.push(nx);
      }
    }
  }
  ans = 0;
  for (int i = 0; i < n - 1; i++) {
    for (int j = 0; j < m - 1; j++)
      if (vis[i][j] != 2) ans += (X[i + 1] - X[i]) * (Y[j + 1] - Y[j]);
  }
  printf("%lld", ans);
  return 0;
}
