#include <bits/stdc++.h>
using namespace std;
set<int> v1;
set<int> v2;
vector<pair<int, int> > list1;
vector<pair<int, int> > list2;
vector<pair<int, int> > v;
int d[5000][5000];
void dfs(int x, int y) {
  d[x][y] = 2;
  if (x + 1 < list1.size() && d[x + 1][y] == 0) dfs(x + 1, y);
  if (y + 1 < list2.size() && d[x][y + 1] == 0) dfs(x, y + 1);
  if (x - 1 >= 0 && d[x - 1][y] == 0) dfs(x - 1, y);
  if (y - 1 >= 0 && d[x][y - 1] == 0) dfs(x, y - 1);
}
int main() {
  string s;
  int x;
  int n;
  cin >> n;
  int x1 = 0;
  int x2 = 0;
  v1.insert(x1);
  v2.insert(x2);
  v.push_back(make_pair(0, 0));
  for (int i = 0; i < n; i++) {
    cin >> s >> x;
    if (s == "R") x1 += x;
    if (s == "L") x1 -= x;
    if (s == "U") x2 += x;
    if (s == "D") x2 -= x;
    v1.insert(x1);
    v2.insert(x2);
    v.push_back(make_pair(x1, x2));
  }
  int last = -1;
  int cnt = 0;
  for (set<int>::iterator it = v1.begin(); it != v1.end(); it++) {
    if (cnt != 0) {
      if (last <= *it - 1) list1.push_back(make_pair(last, *it - 1));
    }
    list1.push_back(make_pair(*it, *it));
    last = *it + 1;
    cnt++;
  }
  for (set<int>::iterator it = v2.begin(); it != v2.end(); it++) {
    if (cnt != 0) {
      if (last <= *it - 1) list2.push_back(make_pair(last, *it - 1));
    }
    list2.push_back(make_pair(*it, *it));
    last = *it + 1;
    cnt++;
  }
  for (int i = 0; i < list1.size(); i++)
    for (int j = 0; j < list2.size(); j++) d[i][j] = 0;
  for (int i = 0; i < v.size(); i++) {
    int l = -1;
    int r = list1.size();
    while (r - l > 1) {
      int m = (l + r) / 2;
      if (list1[m].first > v[i].first)
        r = m;
      else
        l = m;
    }
    v[i].first = l;
    l = -1;
    r = list2.size();
    while (r - l > 1) {
      int m = (l + r) / 2;
      if (list2[m].first > v[i].second)
        r = m;
      else
        l = m;
    }
    v[i].second = l;
  }
  for (int i = 1; i < v.size(); i++) {
    if (v[i - 1].first < v[i].first) {
      for (int j = v[i - 1].first; j <= v[i].first; j++)
        d[j][v[i - 1].second] = 1;
    }
    if (v[i - 1].first > v[i].first) {
      for (int j = v[i].first; j <= v[i - 1].first; j++)
        d[j][v[i - 1].second] = 1;
    }
    if (v[i - 1].second < v[i].second) {
      for (int j = v[i - 1].second; j <= v[i].second; j++)
        d[v[i - 1].first][j] = 1;
    }
    if (v[i].second < v[i - 1].second) {
      for (int j = v[i].second; j <= v[i - 1].second; j++)
        d[v[i - 1].first][j] = 1;
    }
  }
  for (int i = 0; i < list2.size(); i++) {
    if (d[0][i] == 0) dfs(0, i);
    if (d[list1.size() - 1][i] == 0) dfs(list1.size() - 1, i);
  }
  for (int i = 0; i < list1.size(); i++) {
    if (d[i][0] == 0) dfs(i, 0);
    if (d[i][list2.size() - 1] == 0) dfs(i, list2.size() - 1);
  }
  long long ans = 0;
  for (int i = 0; i < list1.size(); i++) {
    for (int j = 0; j < list2.size(); j++) {
      if (d[i][j] != 2)
        ans += 1ll * (list1[i].second - list1[i].first + 1) *
               (1 + list2[j].second - list2[j].first);
    }
  }
  cout << ans;
  return 0;
}
