#include <bits/stdc++.h>
using namespace std;
const int dx[] = {-1, 1, 0, 0};
const int dy[] = {0, 0, -1, 1};
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<pair<int, int> > input(n);
  long long cur_x = 5000000000ll, cur_y = 5000000000ll;
  vector<long long> x_log, y_log;
  x_log.push_back(cur_x);
  x_log.push_back(cur_x + 1);
  y_log.push_back(cur_y);
  y_log.push_back(cur_y + 1);
  for (int i = 0; i < n; ++i) {
    string s;
    int x, dir = 0;
    cin >> s >> x;
    switch (s[0]) {
      case 'L':
        dir = 0;
        break;
      case 'R':
        dir = 1;
        break;
      case 'U':
        dir = 2;
        break;
      case 'D':
        dir = 3;
        break;
    }
    input[i] = pair<int, int>(x, dir);
    cur_x += x * dx[dir];
    cur_y += x * dy[dir];
    x_log.push_back(cur_x);
    x_log.push_back(cur_x + 1);
    y_log.push_back(cur_y);
    y_log.push_back(cur_y + 1);
  }
  sort(x_log.begin(), x_log.end());
  x_log.erase(unique(x_log.begin(), x_log.end()), x_log.end());
  sort(y_log.begin(), y_log.end());
  y_log.erase(unique(y_log.begin(), y_log.end()), y_log.end());
  vector<vector<int> > passed(y_log.size(), vector<int>(x_log.size()));
  cur_x = 5000000000ll, cur_y = 5000000000ll;
  for (int i = 0; i < n; ++i) {
    int x = input[i].first, dir = input[i].second;
    int x_begin =
        lower_bound(x_log.begin(), x_log.end(), cur_x) - x_log.begin();
    int y_begin =
        lower_bound(y_log.begin(), y_log.end(), cur_y) - y_log.begin();
    cur_x += x * dx[dir];
    cur_y += x * dy[dir];
    int x_end = lower_bound(x_log.begin(), x_log.end(), cur_x) - x_log.begin();
    int y_end = lower_bound(y_log.begin(), y_log.end(), cur_y) - y_log.begin();
    if (x_begin > x_end) {
      swap(x_begin, x_end);
    }
    if (y_begin > y_end) {
      swap(y_begin, y_end);
    }
    for (int j = y_begin; j <= y_end; ++j) {
      for (int k = x_begin; k <= x_end; ++k) {
        passed[j][k] = 1;
      }
    }
  }
  vector<vector<int> > infected(y_log.size(), vector<int>(x_log.size()));
  for (int i = 0; i + 1 < y_log.size(); ++i) {
    for (int j = 0; j + 1 < x_log.size(); ++j) {
      if (i != 0 && i + 2 != y_log.size() && j != 0 && j + 2 != x_log.size()) {
        continue;
      }
      if (passed[i][j] || infected[i][j]) {
        continue;
      }
      queue<pair<int, int> > q;
      infected[i][j] = 1;
      q.push(pair<int, int>(i, j));
      while (!q.empty()) {
        int y = q.front().first, x = q.front().second;
        q.pop();
        for (int k = 0; k < 4; ++k) {
          int ny = y + dy[k], nx = x + dx[k];
          if (ny < 0 || ny >= y_log.size() || nx < 0 || nx >= x_log.size()) {
            continue;
          }
          if (infected[ny][nx] || passed[ny][nx]) {
            continue;
          }
          infected[ny][nx] = 1;
          q.push(pair<int, int>(ny, nx));
        }
      }
    }
  }
  long long answer = 0;
  for (int i = 0; i + 1 < y_log.size(); ++i) {
    for (int j = 0; j + 1 < x_log.size(); ++j) {
      if (infected[i][j]) {
        continue;
      }
      long long w = x_log[j + 1] - x_log[j], h = y_log[i + 1] - y_log[i];
      answer += w * h;
    }
  }
  cout << answer << endl;
  return 0;
}
