#include <bits/stdc++.h>
using namespace std;
struct Rectangle {
  int X0, X1, Y0, Y1;
};
int Get() {
  char c;
  while (c = getchar(), c < '0' || c > '9')
    ;
  int X = 0;
  while (c >= '0' && c <= '9') {
    X = X * 10 + c - 48;
    c = getchar();
  }
  return X;
}
char GetDirection() {
  char c;
  while (c = getchar(), c < 'A' || c > 'Z') return c;
}
const int V[4][2] = {{-1, 0}, {0, -1}, {0, 1}, {1, 0}};
int main() {
  int N = Get(), X = 0, Y = 0;
  static Rectangle A[1000];
  static int DataX[2000], DataY[2000];
  for (int i = 0; i < N; i++) {
    int _X = X, _Y = Y;
    char c = GetDirection();
    int Len = Get();
    if (c == 'R') X += Len;
    if (c == 'U') Y += Len;
    if (c == 'L') X -= Len;
    if (c == 'D') Y -= Len;
    A[i] = (Rectangle){min(X, _X), max(X, _X) + 1, min(Y, _Y), max(Y, _Y) + 1};
    DataX[i * 2] = A[i].X0;
    DataX[i * 2 + 1] = A[i].X1;
    DataY[i * 2] = A[i].Y0;
    DataY[i * 2 + 1] = A[i].Y1;
  }
  sort(DataX, DataX + N * 2);
  sort(DataY, DataY + N * 2);
  int R = 1, C = 1;
  for (int i = 1; i < N * 2; i++) {
    if (DataX[i] != DataX[i - 1]) DataX[R++] = DataX[i];
    if (DataY[i] != DataY[i - 1]) DataY[C++] = DataY[i];
  }
  static bool Map[2000][2000];
  for (int i = 0; i < N; i++) {
    int P0 = 0;
    while (DataX[P0] < A[i].X0) P0++;
    int P1 = P0;
    while (DataX[P1] < A[i].X1) P1++;
    int Q0 = 0;
    while (DataY[Q0] < A[i].Y0) Q0++;
    int Q1 = Q0;
    while (DataY[Q1] < A[i].Y1) Q1++;
    for (int j = P0; j < P1; j++)
      for (int k = Q0; k < Q1; k++) Map[j][k] = true;
  }
  static bool Flag[2000][2000];
  for (int i = 0; i < R; i++)
    for (int j = 0; j < C; j++) {
      if (Map[i][j] || Flag[i][j]) continue;
      int Begin = 0, End = 1;
      static int Qx[4000000], Qy[4000000];
      Qx[0] = i;
      Qy[0] = j;
      Flag[i][j] = true;
      while (Begin < End) {
        int X0 = Qx[Begin], Y0 = Qy[Begin];
        Begin++;
        for (int D = 0; D < 4; D++) {
          int X1 = X0 + V[D][0], Y1 = Y0 + V[D][1];
          if (X1 < 0 || X1 == R || Y1 < 0 || Y1 == C) continue;
          if (Map[X1][Y1] || Flag[X1][Y1]) continue;
          Qx[End] = X1;
          Qy[End] = Y1;
          End++;
          Flag[X1][Y1] = true;
        }
      }
      bool Out = false;
      for (int k = 0; !Out && k < End; k++)
        Out = (!Qx[k]) || (Qx[k] == R - 1) || (!Qy[k]) || (Qy[k] == C - 1);
      if (!Out)
        for (int k = 0; k < End; k++) Map[Qx[k]][Qy[k]] = true;
    }
  long long Ans = 0;
  for (int i = 1; i < R; i++)
    for (int j = 1; j < C; j++)
      if (Map[i - 1][j - 1])
        Ans += (long long)(DataX[i] - DataX[i - 1]) * (DataY[j] - DataY[j - 1]);
  cout << Ans << endl;
  return 0;
}
