#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  string s;
  int c = 0;
  char f[1000000];
  vector<long long int> loop;
  int j = 0;
  int k = 0;
  loop.push_back(1);
  unsigned long long int b = 0;
  unsigned long long int p = 1;
  for (int i = 0; i < n; i++) {
    cin >> s;
    if (s == "for") {
      cin >> j;
      p *= j;
      if (p > 4294967295) {
        p = 4294967296;
      }
      loop.push_back(p);
    } else if (s == "add") {
      b += p;
    } else {
      loop.pop_back();
      p = loop.back();
    }
    if (b > 4294967295) {
      cout << "OVERFLOW!!!";
      return 0;
    }
  }
  cout << b;
  return 0;
}
