#include <bits/stdc++.h>
using namespace std;
vector<long long> posx, posy;
int rd[3010][3010];
long long val[3010];
char t[3010];
void dfs(int x, int y) {
  if (x >= posx.size() || y >= posy.size() || x < 0 || y < 0 || rd[x][y])
    return;
  rd[x][y] = 2;
  dfs(x + 1, y);
  dfs(x - 1, y);
  dfs(x, y + 1);
  dfs(x, y - 1);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  long long curx = 10000000000LL + 1 / 2, cury = 10000000000LL + 1 / 2;
  posx.push_back(0);
  posx.push_back(10000000000LL + 1 - 1);
  posy.push_back(0);
  posy.push_back(10000000000LL + 1 - 1);
  posx.push_back(curx);
  posx.push_back(curx + 1);
  posy.push_back(cury);
  posy.push_back(cury + 1);
  for (int i = 0; i < n; i++) {
    cin >> t[i] >> val[i];
    if (t[i] == 'U') curx += val[i];
    if (t[i] == 'D') curx -= val[i];
    if (t[i] == 'L') cury -= val[i];
    if (t[i] == 'R') cury += val[i];
    posx.push_back(curx);
    posx.push_back(curx + 1);
    posy.push_back(cury);
    posy.push_back(cury + 1);
  }
  sort(posx.begin(), posx.end());
  sort(posy.begin(), posy.end());
  posx.erase(unique(posx.begin(), posx.end()), posx.end());
  posy.erase(unique(posy.begin(), posy.end()), posy.end());
  curx = 10000000000LL + 1 / 2;
  cury = 10000000000LL + 1 / 2;
  for (int i = 0; i < n; i++) {
    int curxi = lower_bound(posx.begin(), posx.end(), curx) - posx.begin();
    int curyi = lower_bound(posy.begin(), posy.end(), cury) - posy.begin();
    if (t[i] == 'U') curx += val[i];
    if (t[i] == 'D') curx -= val[i];
    if (t[i] == 'L') cury -= val[i];
    if (t[i] == 'R') cury += val[i];
    int xi = lower_bound(posx.begin(), posx.end(), curx) - posx.begin();
    int yi = lower_bound(posy.begin(), posy.end(), cury) - posy.begin();
    if (xi < curxi) swap(xi, curxi);
    if (yi < curyi) swap(yi, curyi);
    for (int i = curxi; i <= xi; i++)
      for (int j = curyi; j <= yi; j++) {
        rd[i][j] = 1;
      }
  }
  dfs(0, 0);
  long long ans = 0;
  for (int i = 0; i < posx.size() - 1; i++)
    for (int j = 0; j < posy.size() - 1; j++) {
      if (rd[i][j] != 2) {
        ans += (posx[i + 1] - posx[i]) * (posy[j + 1] - posy[j]);
      }
    }
  cout << ans << '\n';
}
