#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
struct Node {
  int x1, x2, y1, y2;
  Node() {}
  Node(int _x1, int _y1, int _x2, int _y2)
      : x1(_x1), y1(_y1), x2(_x2), y2(_y2) {}
} rec[1005];
int way[4][2] = {0, 1, 0, -1, 1, 0, -1, 0};
int m;
int vis[2005][2005] = {0};
vector<long long> x, y;
queue<pair<long long, long long> > que;
int id(char ch) {
  if (ch == 'R') return 0;
  if (ch == 'L') return 1;
  if (ch == 'U') return 3;
  return 2;
}
int Bin(vector<long long> v, long long num) {
  return find(v.begin(), v.end(), num) - v.begin();
}
int main() {
  int x1 = 0, y1 = 0, x2, y2;
  scanf("%d", &m);
  x.push_back(-10000000005LL);
  x.push_back(10000000005LL);
  y.push_back(-10000000005LL);
  y.push_back(10000000005LL);
  for (int i = 0; i < m; i++) {
    char str[5];
    int val;
    scanf("%s%d", &str, &val);
    int idx = id(str[0]);
    x2 = x1 + way[idx][0] * val;
    y2 = y1 + way[idx][1] * val;
    x.push_back(min(x1, x2));
    x.push_back(max(x1, x2) + 1);
    y.push_back(min(y1, y2));
    y.push_back(max(y1, y2) + 1);
    rec[i] = Node(min(x1, x2), min(y1, y2), max(x1, x2) + 1, max(y1, y2) + 1);
    x1 = x2;
    y1 = y2;
  }
  sort(x.begin(), x.end());
  sort(y.begin(), y.end());
  x.resize(unique(x.begin(), x.end()) - x.begin());
  y.resize(unique(y.begin(), y.end()) - y.begin());
  for (int i = 0; i < m; i++) {
    x1 = Bin(x, rec[i].x1);
    x2 = Bin(x, rec[i].x2) - 1;
    y1 = Bin(y, rec[i].y1);
    y2 = Bin(y, rec[i].y2) - 1;
    for (int j = x1; j <= x2; j++)
      for (int k = y1; k <= y2; k++) vis[j][k] = 1;
  }
  que.push(make_pair(0, 0));
  vis[0][0] = 2;
  while (!que.empty()) {
    pair<long long, long long> u, v;
    u = que.front();
    que.pop();
    for (int i = 0; i < 4; i++) {
      v = u;
      v.first += way[i][0];
      v.second += way[i][1];
      if (v.first >= 0 && v.first < x.size() && v.second >= 0 &&
          v.second < y.size() && vis[v.first][v.second] == 0) {
        vis[v.first][v.second] = 2;
        que.push(v);
      }
    }
  }
  long long ans = 0;
  for (int i = 0; i < x.size() - 1; i++)
    for (int j = 0; j < y.size() - 1; j++)
      if (vis[i][j] != 2)
        ans += (long long)(x[i + 1] - x[i]) * (y[j + 1] - y[j]);
  printf("%I64d\n", ans);
  return 0;
}
