#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:16777216 )   const long long inf = 2147383647;   const double pi = 2 * acos(0.0);   const double eps = 1e-9;   const long long maxint = 2147483647;   const long long minint = -2147483648;   using namespace std;   struct Bigint {     string a;     int sign;     Bigint() {}     Bigint(string b) { (*this) = b; }     int size() { return a.size(); }     Bigint inverseSign() {       sign *= -1;       return (*this);     }     Bigint normalize(int newSign) {       for (int i = a.size() - 1; i > 0 && a[i] ==  0 ; i--)         a.erase(a.begin() + i);       sign = (a.size() == 1 && a[0] ==  0 ) ? 1 : newSign;       return (*this);     }     void operator=(string b) {       a = b[0] ==  -  ? b.substr(1) : b;       reverse(a.begin(), a.end());       this->normalize(b[0] ==  -  ? -1 : 1);     }     void operator=(long long num) {       char buf[30];       sprintf(buf,  %lld , num);       *this = buf;     }     bool operator<(const Bigint &b) const {       if (sign != b.sign) return sign < b.sign;       if (a.size() != b.a.size())         return sign == 1 ? a.size() < b.a.size() : a.size() > b.a.size();       for (int i = a.size() - 1; i >= 0; i--)         if (a[i] != b.a[i]) return sign == 1 ? a[i] < b.a[i] : a[i] > b.a[i];       return false;     }     bool operator==(const Bigint &b) const { return a == b.a && sign == b.sign; }     Bigint operator+(Bigint b) {       if (sign != b.sign) return (*this) - b.inverseSign();       Bigint c;       for (int i = 0, carry = 0; i < a.size() || i < b.size() || carry; i++) {         carry +=             (i < a.size() ? a[i] - 48 : 0) + (i < b.a.size() ? b.a[i] - 48 : 0);         c.a += (carry % 10 + 48);         carry /= 10;       }       return c.normalize(sign);     }     Bigint operator-(Bigint b) {       if (sign != b.sign) return (*this) + b.inverseSign();       int s = sign;       sign = b.sign = 1;       if ((*this) < b) return ((b - (*this)).inverseSign()).normalize(-s);       Bigint c;       for (int i = 0, borrow = 0; i < a.size(); i++) {         borrow = a[i] - borrow - (i < b.size() ? b.a[i] : 48);         c.a += borrow >= 0 ? borrow + 48 : borrow + 58;         borrow = borrow >= 0 ? 0 : 1;       }       return c.normalize(s);     }     Bigint operator*(Bigint b) {       Bigint c( 0 );       for (int i = 0, k = a[i] - 48; i < a.size(); i++, k = a[i] - 48) {         while (k--) c = c + b;         b.a.insert(b.a.begin(),  0 );       }       return c.normalize(sign * b.sign);     }     Bigint operator/(Bigint b) {       if (b.size() == 1 && b.a[0] ==  0 ) b.a[0] /= (b.a[0] - 48);       Bigint c( 0 ), d;       for (int j = 0; j < a.size(); j++) d.a +=  0 ;       int dSign = sign * b.sign;       b.sign = 1;       for (int i = a.size() - 1; i >= 0; i--) {         c.a.insert(c.a.begin(),  0 );         c = c + a.substr(i, 1);         while (!(c < b)) c = c - b, d.a[i]++;       }       return d.normalize(dSign);     }     Bigint operator%(Bigint b) {       if (b.size() == 1 && b.a[0] ==  0 ) b.a[0] /= (b.a[0] - 48);       Bigint c( 0 );       b.sign = 1;       for (int i = a.size() - 1; i >= 0; i--) {         c.a.insert(c.a.begin(),  0 );         c = c + a.substr(i, 1);         while (!(c < b)) c = c - b;       }       return c.normalize(sign);     }     void print() {       if (sign == -1) putchar( - );       for (int i = a.size() - 1; i >= 0; i--) putchar(a[i]);     }     Bigint operator*(long long b) {       long long carry = 0;       Bigint c = *this;       int bsign;       if (b < 0) {         bsign = -1;         b *= -1;       } else         bsign = 1;       for (int i = 0; i < c.a.size(); i++) {         carry += (c.a[i] - 48) * b;         c.a[i] = (carry % 10 + 48);         carry /= 10;       }       while (carry) {         c.a += (carry % 10 + 48);         carry /= 10;       }       return c.normalize(sign * bsign);     }   };   Bigint power[2001];   void init() {     power[0] =  1 ;     int i;     for (i = 1; i <= 2000; i++) {       power[i] = power[i - 1] * 2;     }   }   struct drive {     int value;     bool sell;   } arr[5010];   Bigint res;   void use(int buy, int sell) {     if (buy == inf) {       if (sell != inf)         arr[sell].value = inf - 10;       else         return;     } else {       res = res + power[arr[sell].value];       for (int i = buy; i <= sell; i++) arr[i].value = inf;     }   }   int main() {     init();     int size;     scanf( %d , &size);     int i;     char buf[200];     for (i = 0; i < size; i++) {       scanf( %s %d , buf, &arr[i].value);       arr[i].sell = false;       if (buf[0] ==  s ) {         arr[i].sell = true;       }     }     res =  0 ;     int k = 5000;     while (k--) {       int sell = inf, buy = inf, mx = -1;       for (i = size - 1; i >= 0; i--) {         if (arr[i].value == inf) {           use(buy, sell);           sell = inf;           buy = inf;           mx = -1;           continue;         }         if (arr[i].sell) {           if (arr[i].value == inf - 10) continue;           if (arr[i].value >= mx) {             mx = arr[i].value;             sell = i;             buy = inf;           }         } else {           if (arr[i].value == mx && buy == inf) {             buy = i;           }         }       }       use(buy, sell);     }     res.print();     puts(  );     return 0;   }