#include <bits/stdc++.h>
using namespace std;
pair<int, int> in[1010];
int n;
vector<long long> xs, ys;
int mm[3000][3000];
string dir("LRUD");
int dx[] = {-1, +1, 0, 0};
int dy[] = {0, 0, +1, -1};
inline int pos(vector<long long>& as, long long a) {
  return lower_bound(as.begin(), as.end(), a) - as.begin();
}
int main(int argc, const char** argv) {
  cin >> n;
  int i, j;
  set<long long> x, y;
  x.insert((long long)-5e9 - 1);
  x.insert((long long)5e9);
  x.insert(0LL);
  x.insert(1LL);
  y.insert((long long)-5e9 - 1);
  y.insert((long long)5e9);
  y.insert(0LL);
  y.insert(1LL);
  long long x0 = 0LL, y0 = 0LL;
  in[0] = make_pair(0, 0);
  for ((i) = 0; (i) < (int)(n); (i)++) {
    char c;
    int d;
    cin >> c >> d;
    j = dir.find(c);
    x0 += dx[j] * d;
    y0 += dy[j] * d;
    x.insert(x0);
    x.insert(x0 + 1);
    y.insert(y0);
    y.insert(y0 + 1);
    in[i + 1].first = x0;
    in[i + 1].second = y0;
  }
  copy(x.begin(), x.end(), back_inserter(xs));
  copy(y.begin(), y.end(), back_inserter(ys));
  for ((i) = 0; (i) < (int)(n); (i)++) {
    int xst = pos(xs, in[i].first), xed = pos(xs, in[i + 1].first),
        yst = pos(ys, in[i].second), yed = pos(ys, in[i + 1].second);
    if (xst > xed) swap(xst, xed);
    if (yst > yed) swap(yst, yed);
    for (int xp = xst; xp <= xed; ++xp)
      for (int yp = yst; yp <= yed; ++yp) {
        mm[xp][yp] = 1;
      }
  }
  queue<int> xq, yq;
  xq.push(0);
  yq.push(0);
  while (!xq.empty()) {
    int xt = xq.front();
    xq.pop();
    int yt = yq.front();
    yq.pop();
    if (mm[xt][yt] >= 1) continue;
    mm[xt][yt] = 2;
    for ((i) = 0; (i) < (int)(4); (i)++) {
      int nx = xt + dx[i], ny = yt + dy[i];
      if (nx >= 0 && nx <= xs.size() && ny >= 0 && ny <= ys.size()) {
        xq.push(nx);
        yq.push(ny);
      }
    }
  }
  long long ans = 0;
  for ((j) = 0; (j) < (int)(ys.size() + 1); (j)++) {
    for ((i) = 0; (i) < (int)(xs.size() + 1); (i)++) {
      if (mm[i][j] <= 1) {
        ans += (xs[i + 1] - xs[i]) * (ys[j + 1] - ys[j]);
      }
    }
  }
  cout << ans << endl;
  return 0;
}
