#include <bits/stdc++.h>
#pragma gcc optimize("Ofast")
using namespace std;
template <typename T>
using maxHeap = priority_queue<T, vector<T>, less<T>>;
template <typename T>
using minHeap = priority_queue<T, vector<T>, greater<T>>;
inline void input(int& _x) {
  _x = 0;
  int _tmp = 1;
  char _tc = getchar();
  while ((_tc < '0' || _tc > '9') && _tc != '-') _tc = getchar();
  if (_tc == '-') _tc = getchar(), _tmp = -1;
  while (_tc >= '0' && _tc <= '9') _x = _x * 10 + (_tc - 48), _tc = getchar();
  _x *= _tmp;
}
inline void output(int _x) {
  char _buff[20];
  int _f = 0;
  if (_x == 0) putchar('0');
  while (_x > 0) {
    _buff[_f++] = _x % 10 + '0';
    _x /= 10;
  }
  for (_f -= 1; _f >= 0; _f--) putchar(_buff[_f]);
  putchar('\n');
}
template <typename Iter>
ostream& _out(ostream& s, Iter b, Iter e) {
  s << "[";
  for (auto it = b; it != e; it++) s << (it == b ? "" : " ") << *it;
  s << "]";
  return s;
}
template <class T1, class T2>
ostream& operator<<(ostream& out, pair<T1, T2> p) {
  return out << '(' << p.first << ", " << p.second << ')';
}
template <typename T>
ostream& operator<<(ostream& s, const vector<T>& c) {
  return _out(s, c.begin(), c.end());
}
pair<int, int> operator+(pair<int, int> a, pair<int, int> b) {
  return {a.first + b.first, a.second + b.second};
}
pair<int, int>& operator+=(pair<int, int>& a, pair<int, int> b) {
  a.first += b.first, a.second += b.second;
  return a;
}
pair<int, int> operator*(pair<int, int> a, int b) {
  return {a.first * b, a.second * b};
}
pair<int, int> dir(char c) {
  if (c == 'U') return {0, 1};
  if (c == 'D') return {0, -1};
  if (c == 'R') return {1, 0};
  if (c == 'L')
    return {-1, 0};
  else
    exit((cout << (int)c << '\n', 0));
}
vector<pair<int, int>> pos;
vector<char> ds;
vector<int> xs, ys;
vector<vector<int>> mp;
bool valid(pair<int, int> p) {
  return p.first < (int)xs.size() + 2 && p.first >= 0 &&
         p.second < (int)ys.size() + 2 && p.second >= 0;
}
int& get(pair<int, int> x) { return mp[x.first][x.second]; }
void dfs(pair<int, int> x) {
  get(x) = 2;
  for (char c : "UDLR")
    if (c && valid(x + dir(c)) && !get(x + dir(c))) dfs(x + dir(c));
}
signed main() {
  int n;
  cin >> n;
  pair<int, int> p = {0, 0};
  pos.push_back(p);
  xs.push_back(0);
  ys.push_back(0);
  xs.push_back(1);
  ys.push_back(1);
  for (int i = 0; i < n; i++) {
    char c;
    int a;
    cin >> c >> a;
    p += dir(c) * a;
    ds.push_back(c);
    xs.push_back(p.first);
    xs.push_back(p.first + 1);
    ys.push_back(p.second);
    ys.push_back(p.second + 1);
    pos.push_back(p);
  }
  sort((xs).begin(), (xs).end());
  xs.erase(unique((xs).begin(), (xs).end()), xs.end());
  sort((ys).begin(), (ys).end());
  ys.erase(unique((ys).begin(), (ys).end()), ys.end());
  for (auto& [x, y] : pos)
    x = lower_bound((xs).begin(), (xs).end(), x) - xs.begin() + 1,
    y = lower_bound((ys).begin(), (ys).end(), y) - ys.begin() + 1;
  mp.resize(xs.size() + 2);
  for (auto& i : mp) i.resize(ys.size() + 2);
  for (int i = 0; i < n; i++)
    for (pair<int, int> c = pos[i]; c != pos[i + 1]; c += dir(ds[i]))
      get(c) = 1;
  get(pos[n]) = 1;
  dfs({0, 0});
  int64_t ans = 0;
  for (int i = 1; i <= xs.size(); i++)
    for (int j = 1; j <= ys.size(); j++)
      if (mp[i][j] != 2)
        ans += (int64_t)(xs[i] - xs[i - 1]) * (ys[j] - ys[j - 1]);
  cout << ans << '\n';
}
