#include <bits/stdc++.h>
using namespace std;
const long long OF = 1LL << 32;
long long LOOP(void) {
  char s[5];
  long long x = 0, ans = 0;
  while (scanf("%s", s) != EOF && ans < OF) {
    if (s[0] == 'a')
      ++ans;
    else if (s[0] == 'f') {
      scanf("%lld", &x);
      x *= LOOP();
      ans += x;
    } else if (s[0] == 'e')
      return ans;
  }
  printf("OVERFLOW!!!");
  exit(0);
}
int main(void) {
  long long x = 0, ans = 0;
  char s[5];
  scanf("%lld", &x);
  while (scanf("%s", s) != EOF && ans < OF) {
    if (s[0] == 'a') {
      ++ans;
      continue;
    }
    scanf("%lld", &x);
    x *= LOOP();
    ans += x;
  }
  if (ans >= OF) {
    printf("OVERFLOW!!!");
    return 0;
  }
  printf("%lld", ans);
  return 0;
}
