#include <bits/stdc++.h>
using namespace std;
const long long INF = 10000000000LL;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
int mark[3007][3007];
vector<long long> xx, yy;
int n, cnt[1007];
char op[1007];
long long res;
void work(int x1, int y1, int x2, int y2) {
  if (x1 > x2) {
    swap(x1, x2);
  }
  if (y1 > y2) {
    swap(y1, y2);
  }
  for (int i = x1; i <= x2; i++) {
    for (int j = y1; j <= y2; j++) {
      mark[i][j] = 1;
    }
  }
}
void dfs(int i, int j) {
  mark[i][j] = 2;
  for (int k = 0; k < 4; ++k) {
    int x = i + dx[k];
    int y = j + dy[k];
    if (x >= 0 && y >= 0 && x < xx.size() && y < yy.size() && !mark[x][y]) {
      dfs(x, y);
    }
  }
}
int main() {
  int i, j;
  cin >> n;
  long long x = INF / 2;
  long long y = INF / 2;
  xx.push_back(0);
  yy.push_back(0);
  xx.push_back(INF);
  yy.push_back(INF);
  xx.push_back(x);
  yy.push_back(y);
  xx.push_back(x + 1);
  yy.push_back(y + 1);
  for (i = 0; i < n; ++i) {
    cin >> op[i] >> cnt[i];
    if (op[i] == 'R') {
      x += cnt[i];
    } else if (op[i] == 'L') {
      x -= cnt[i];
    } else if (op[i] == 'U') {
      y += cnt[i];
    } else {
      y -= cnt[i];
    }
    xx.push_back(x);
    yy.push_back(y);
    xx.push_back(x + 1);
    yy.push_back(y + 1);
  }
  sort((xx).begin(), (xx).end());
  sort((yy).begin(), (yy).end());
  xx.resize(unique((xx).begin(), (xx).end()) - xx.begin());
  yy.resize(unique((yy).begin(), (yy).end()) - yy.begin());
  i = lower_bound((xx).begin(), (xx).end(), INF / 2) - xx.begin();
  j = lower_bound((yy).begin(), (yy).end(), INF / 2) - yy.begin();
  x = xx[i];
  y = yy[j];
  for (int k = 0; k < n; ++k) {
    int oldi = i;
    int oldj = j;
    if (op[k] == 'R') {
      x += cnt[k];
    } else if (op[k] == 'L') {
      x -= cnt[k];
    } else if (op[k] == 'U') {
      y += cnt[k];
    } else {
      y -= cnt[k];
    }
    i = lower_bound((xx).begin(), (xx).end(), x) - xx.begin();
    j = lower_bound((yy).begin(), (yy).end(), y) - yy.begin();
    work(oldi, oldj, i, j);
  }
  dfs(0, 0);
  for (i = 0; i < xx.size() - 1; ++i) {
    for (j = 0; j < yy.size() - 1; ++j) {
      if (mark[i][j] != 2) {
        res += (xx[i + 1] - xx[i]) * (yy[j + 1] - yy[j]);
      }
    }
  }
  cout << res << endl;
  return 0;
}
