#include <cstdio>
#include <cstring>

#include <vector>
#include <string>
#include <algorithm>

using namespace std;

string dp[5001];
vector<int> win[2001];
int n;

string pow2[2001];

void multi2( string &ress , const string &p ){

    int flag = 0;
    ress = "";
    for( int i = 0 ; i < p.size() ; i ++ ){
        ress += ( ( p[i] - '0' ) * 2 + flag ) % 10 + '0';
        flag = ( ( p[i] - '0' ) * 2 + flag ) / 10;
    }

    if( flag )
        ress += '1';

    int pos = ress.size() - 1;
    for( ; pos >= 0 && ress[pos] == '0' ; pos -- );
    ress = ress.substr( 0 , pos + 1 );

    if( ress == "" )
        ress = "0";

    return;
}

void initPow2( void ){

    pow2[0] = "1";
    for( int i = 1; i <= 2000 ; i ++ )
        multi2( pow2[i] , pow2[i-1] );

    return;
}

void add( string &ress , string num ){

    while( ress.size() < num.size() )
        ress += '0';

    while( num.size() < ress.size() )
        num += '0';

    int flag = 0;
    for( int i = 0 ; i < ress.size() ; i ++ ){
        char tRes = ( ress[i] - '0' + num[i] - '0' + flag ) % 10 + '0';
        flag = ( ress[i] - '0' + num[i] - '0' + flag ) / 10;

        ress[i] = tRes;
    }

    if( flag )
        ress += '1';

    int pos = ress.size() - 1;
    for( ; pos >= 0 && ress[pos] == '0' ; pos -- );
    ress = ress.substr( 0 , pos + 1 );

    if( ress == "" )
        ress = "0";

    return;
}

bool larger( const string &str1 , const string &str2 ){

    if( str1.size() > str2.size() )
        return true;

    if( str1.size() < str2.size() )
        return false;

    for( int i = str1.size() - 1 ; i >= 0 ; i -- )
        if( str1[i] > str2[i] )
            return true;

    return false;
}

int main( void ){

    char enter;
    char input[10];
    int t;

    dp[0] = "0";
    initPow2();
    for( int i = 0 ; i <= 2000 ; i ++ )
        win[i].clear();

    scanf("%d%c",&n,&enter);
    for( int i = 1 ; i <= n ; i ++ ){
        scanf("%s%c%d%c",input,&enter,&t,&enter);

        if( input[0] == 'w' ){
            win[ t ].push_back( i );
            dp[i] = dp[i-1];
        }
        else{

            dp[i] = dp[i-1];
            if( win[t].size() != 0 ){

                for( int j = 0 ; j < win[t].size() ; j ++ ){
                    string temp = pow2[ t ];
                    add( temp , dp[ win[t][j]-1 ] );

                    if( larger( temp , dp[i] ) )
                        dp[i] = temp;
                }
            }

        }
    }

    reverse( dp[n].begin() , dp[n].end() );
    printf("%s\n",dp[n].c_str());

    //system("pause");

    return 0;
}


#include <cstdio>
#include <cstring>

#include <algorithm>
#include <vector>
#include <string>

using namespace std;

typedef struct Event{

    char type;
    int x;
}E;

typedef struct Pre{

    int pre;
    int is;
    int index;
}P;

E e[5001];
int n;

int dp[5001];
P p[5001];
vector<int> res;

string pow2[2001];

void solve( void ){

    int val;

    memset( dp , 0 , sizeof( dp ) );
    for( int i = 0 ; i <= n ; i ++ ){
        p[i].pre = p[i].is = 0;
        p[i].index = i;
    }
    p[0].is = 1;

    for( int i = 1 ; i <= n ; i ++ )
        if( e[i].type == 's' ){

            bool flag = false;

            for( int j = i-1 ; j >= 0 ; j -- ){

                if( e[j].type == 'w' && e[j].x == e[i].x )
                    flag = true;
                if( e[j].type == 's' ){

                    val = dp[j] + (flag?e[i].x:0);
                    if( val > dp[i] ){
                        dp[i] = val;
                        p[i].pre = j;
                        p[i].is = ( flag ? 1 : 0 );
                    }
                }
            }
        }

        return;
}

void findRes( void ){

    int start;
    for( start = n ; ; start -- )
        if( e[start].type == 's' && p[start].is == 1 )
            break;

    res.clear();
    res.push_back( dp[start] );

    P Ppp = p[start];
    while( Ppp.pre != 0 ){

        Ppp = p[Ppp.pre];
        if( Ppp.is == 1 )
            res.push_back( dp[Ppp.index] );
    }

    if( res[res.size()-1] != 0 )
        res.push_back( 0 );

    for( int i = 0 ; i < res.size()-1 ; i ++ )
        res[i] = res[i] - res[i+1];
    res.pop_back();

    return;
}

string mult2( const string &x ){

    string resp = "";

    int flag = 0;
    for( int i = 0 ; i < x.size() ; i ++ ){
        resp += ( ( x[i] - '0' )*2 + flag ) % 10 + '0';
        flag = ( ( x[i] - '0' )*2 + flag ) / 10;
    }

    if( flag == 1 )
        resp += '1';

    return resp;
}

void initPower2( void ){

    pow2[0] = "1";
    for( int i = 1 ; i <= 2000 ; i ++ )
        pow2[i] = mult2( pow2[i-1] );

    return;
}

void add( string &resstr , string x){

    while( resstr.size() < x.size() )
        resstr += '0';

    while( x.size() < resstr.size() )
        x += '0';

    int flag = 0;
    for( int i = 0 ; i < resstr.size() ; i ++ ){
        char tRes = ( resstr[i] - '0' + x[i] - '0' + flag)%10 + '0';
        flag = ( resstr[i] - '0' + x[i] - '0' + flag)/10;

        resstr[i] = tRes;

    }

    if( flag )
        resstr += '1';

    return;
}

int main( void ){

    char enter;
    char input[10];

    e[0].type = 's';
    e[0].x = 0;

    scanf("%d%c",&n,&enter);
    for( int i = 1 ; i <= n ; i ++ ){
        scanf("%s%c%d%c",input,&enter,&e[i].x,&enter);
        e[i].type = input[0];
    }

    solve();
    findRes();

    //for( int i = 0 ; i < res.size() ; i ++ )
    //  printf("%d ",res[i]);
    //printf("\n");

    initPower2();

    //system("pause");
    string resStr = "";
    if( res.size() == 0 )
        printf("0\n");
    else{
        resStr = pow2[ res[0] ];
        for( int i = 1 ; i < res.size() ; i ++ )
            add( resStr , pow2[ res[i] ] );
        reverse( resStr.begin() , resStr.end() );
        printf("%s\n",resStr.c_str());
    }

    return 0;
}


#include <cstdio>
#include <cstring>

#include <algorithm>
#include <vector>
#include <string>

using namespace std;

typedef struct Event{

    char type;
    int x;
}E;

typedef struct Pre{

    int pre;
    int is;
    int index;
}P;

E e[5001];
int n;

int dp[5001];
P p[5001];
vector<int> res;

string pow2[2001];

void solve( void ){

    int val;

    memset( dp , 0 , sizeof( dp ) );
    for( int i = 0 ; i <= n ; i ++ ){
        p[i].pre = p[i].is = 0;
        p[i].index = i;
    }
    p[0].is = 1;

    for( int i = 1 ; i <= n ; i ++ )
        if( e[i].type == 's' ){

            bool flag = false;

            for( int j = i-1 ; j >= 0 ; j -- ){

                if( e[j].type == 'w' && e[j].x == e[i].x )
                    flag = true;
                if( e[j].type == 's' ){

                    val = dp[j] + (flag?e[i].x:0);
                    if( val > dp[i] ){
                        dp[i] = val;
                        p[i].pre = j;
                        p[i].is = ( flag ? 1 : 0 );
                    }
                }
            }
        }

    return;
}

void findRes( void ){

    int start;
    for( start = n ; ; start -- )
        if( e[start].type == 's' && p[start].is == 1 )
            break;

    res.clear();
    res.push_back( dp[start] );

    P Ppp = p[start];
    while( Ppp.pre != 0 ){

        Ppp = p[Ppp.pre];
        if( Ppp.is == 1 )
            res.push_back( dp[Ppp.index] );
    }

    if( res[res.size()-1] != 0 )
        res.push_back( 0 );

    for( int i = 0 ; i < res.size()-1 ; i ++ )
        res[i] = res[i] - res[i+1];
    res.pop_back();

    return;
}

string mult2( const string &x ){

    string resp = "";

    int flag = 0;
    for( int i = 0 ; i < x.size() ; i ++ ){
        resp += ( ( x[i] - '0' )*2 + flag ) % 10 + '0';
        flag = ( ( x[i] - '0' )*2 + flag ) / 10;
    }

    if( flag == 1 )
        resp += '1';

    return resp;
}

void initPower2( void ){

    pow2[0] = "1";
    for( int i = 1 ; i <= 2000 ; i ++ )
        pow2[i] = mult2( pow2[i-1] );

    return;
}

void add( string &resstr , string x){

    while( resstr.size() < x.size() )
        resstr += '0';

    while( x.size() < resstr.size() )
        x += '0';

    int flag = 0;
    for( int i = 0 ; i < resstr.size() ; i ++ ){
        resstr[i] = ( resstr[i] - '0' + x[i] - '0' + flag)%10 + '0';
        flag = ( resstr[i] - '0' + x[i] - '0' + flag)/10;
    }

    if( flag )
        resstr += '1';

    return;
}

int main( void ){

    char enter;
    char input[10];

    e[0].type = 's';
    e[0].x = 0;

    scanf("%d%c",&n,&enter);
    for( int i = 1 ; i <= n ; i ++ ){
        scanf("%s%c%d%c",input,&enter,&e[i].x,&enter);
        e[i].type = input[0];
    }

    solve();
    findRes();

    //for( int i = 0 ; i < res.size() ; i ++ )
    //  printf("%d ",res[i]);
    //printf("\n");

    initPower2();

    //system("pause");
    string resStr = "";
    if( res.size() == 0 )
        printf("0\n");
    else{
        resStr = pow2[ res[0] ];
        for( int i = 1 ; i < res.size() ; i ++ )
            add( resStr , pow2[ res[i] ] );
        reverse( resStr.begin() , resStr.end() );
        printf("%s\n",resStr.c_str());
    }

    return 0;
}


#include <cstdio>
#include <cstring>

#include <vector>
#include <string>
#include <algorithm>

using namespace std;

string dp[5001];
int win[2001];
int n;

string pow2[2001];

void multi2( string &ress , const string &p ){

    int flag = 0;
    ress = "";
    for( int i = 0 ; i < p.size() ; i ++ ){
        ress += ( ( p[i] - '0' ) * 2 + flag ) % 10 + '0';
        flag = ( ( p[i] - '0' ) * 2 + flag ) / 10;
    }

    if( flag )
        ress += '1';

    return;
}

void initPow2( void ){

    pow2[0] = "1";
    for( int i = 1; i <= 2000 ; i ++ )
        multi2( pow2[i] , pow2[i-1] );

    return;
}

void add( string &ress , string num ){

    while( ress.size() < num.size() )
        ress += '0';

    while( num.size() < ress.size() )
        num += '0';

    int flag = 0;
    for( int i = 0 ; i < ress.size() ; i ++ ){
        ress[i] = ( ress[i] - '0' + num[i] - '0' + flag ) % 10 + '0';
        flag = ( ress[i] - '0' + num[i] - '0' + flag ) / 10;
    }

    if( flag )
        ress += '1';

    return;
}

bool larger( const string &str1 , const string &str2 ){

    if( str1.size() > str2.size() )
        return true;

    if( str1.size() < str2.size() )
        return false;

    for( int i = str1.size() - 1 ; i >= 0 ; i -- )
        if( str1[i] > str2[i] )
            return true;

    return false;
}

int main( void ){

    char enter;
    char input[10];
    int t;

    dp[0] = "0";
    initPow2();
    memset( win , -1 ,sizeof( win ) );

    scanf("%d%c",&n,&enter);
    for( int i = 1 ; i <= n ; i ++ ){
        scanf("%s%c%d%c",input,&enter,&t,&enter);

        if( input[0] == 'w' ){
            win[ t ] = i;
            dp[i] = dp[i-1];
        }
        else{

            if( win[t] != -1 ){
                string temp = pow2[ t ];
                add( temp , dp[ win[t]-1] );

                if( larger( temp , dp[i-1] ) )
                    dp[i] = temp;
                else
                    dp[i] = dp[i-1];
            }
            else
                dp[i] = dp[i-1];
        }
    }

    reverse( dp[n].begin() , dp[n].end() );
    printf("%s\n",dp[n].c_str());

    //system("pause");

    return 0;
}


#include <cstdio>
#include <cstring>

#include <vector>
#include <string>
#include <algorithm>

using namespace std;

typedef struct Event{

    char type;
    int x;
    bool flag;
}E;

E e[5001];
int n;
vector<int> res;
string pow2[2001];

bool canSell( int x ){

    int sellPos;
    for( sellPos = n ; sellPos >= 0 ; sellPos -- )
        if( e[sellPos].type == 's' && e[sellPos].x == x )
            break;

    if( sellPos < 0 )
        return false;

    int i;
    for( i = sellPos; i >= 0 && e[i].flag == false ; i -- )
        if( e[i].type == 'w' && e[i].x == x )
            break;

    if( e[i].flag )
        return false;

    for( int j = sellPos ; j >= i ; j -- )
        e[j].flag = true;

    for( int j = i-1 ; e[j].type == 'w' ; j -- )
        e[j].flag = true;

    return true;
}

void multi2( string &ress , const string &p ){

    int flag = 0;
    ress = "";
    for( int i = 0 ; i < p.size() ; i ++ ){
        ress += ( ( p[i] - '0' ) * 2 + flag ) % 10 + '0';
        flag = ( ( p[i] - '0' ) * 2 + flag ) / 10;
    }

    if( flag )
        ress += '1';

    return;
}

void initPow2( void ){

    pow2[0] = "1";
    for( int i = 1; i <= 2000 ; i ++ )
        multi2( pow2[i] , pow2[i-1] );

    return;
}

void add( string &ress , string num ){

    while( ress.size() < num.size() )
        ress.push_back( '0' );

    while( num.size() < ress.size() )
        num.push_back( '0' );

    int flag = 0;
    for( int i = 0 ; i < ress.size() ; i ++ ){

        ress[i] = ( ress[i] - '0' + num[i] - '0' + flag ) % 10 + '0';
        flag = ( ress[i] - '0' + num[i] - '0' + flag ) / 10;
    }

    if( flag )
        ress += '1';

    return;
}

int main( void ){

    char enter;
    char input[10];

    e[0].type = 's';
    e[0].x = -1;
    e[0].flag = true;

    scanf("%d%c",&n,&enter);
    for( int i = 1 ; i <= n ; i ++ ){
        scanf("%s%c%d%c",input,&enter,&e[i].x,&enter);
        e[i].type = input[0];
        e[i].flag = false;
    }

    res.clear();
    for( int i = 2000 ; i >= 0 ; i -- )
        if( canSell( i ) )
            res.push_back( i );

    if( res.size() == 0 )
        printf("0\n");
    else{
        initPow2();
        string resStr = pow2[ res[0] ];
        for( int i = 1 ; i < res.size() ; i ++ )
            add( resStr , pow2[ res[i] ] );

        reverse( resStr.begin() , resStr.end() );
        printf("%s\n",resStr.c_str());
    }

    system("pause");

    return 0;
}


#include <cstdio>
#include <cstring>

#include <vector>
#include <string>
#include <algorithm>

using namespace std;

string dp[5001];
int win[2001];
int n;

string pow2[2001];

void multi2( string &ress , const string &p ){

    int flag = 0;
    ress = "";
    for( int i = 0 ; i < p.size() ; i ++ ){
        ress += ( ( p[i] - '0' ) * 2 + flag ) % 10 + '0';
        flag = ( ( p[i] - '0' ) * 2 + flag ) / 10;
    }

    if( flag )
        ress += '1';

    //int pos = ress.size() - 1;
    //for( ; pos >= 0 && ress[pos] == '0' ; pos -- );
    //ress = ress.substr( 0 , pos + 1 );

    if( ress == "" )
        ress = "0";

    return;
}

void initPow2( void ){

    pow2[0] = "1";
    for( int i = 1; i <= 2000 ; i ++ )
        multi2( pow2[i] , pow2[i-1] );

    return;
}

void add( string &ress , string num ){

    while( ress.size() < num.size() )
        ress += '0';

    while( num.size() < ress.size() )
        num += '0';

    int flag = 0;
    for( int i = 0 ; i < ress.size() ; i ++ ){
        char tRes = ( ress[i] - '0' + num[i] - '0' + flag ) % 10 + '0';
        flag = ( ress[i] - '0' + num[i] - '0' + flag ) / 10;

        ress[i] = tRes;
    }

    if( flag )
        ress += '1';

    //int pos = ress.size() - 1;
    //for( ; pos >= 0 && ress[pos] == '0' ; pos -- );
    //ress = ress.substr( 0 , pos + 1 );

    if( ress == "" )
        ress = "0";

    return;
}

bool larger( const string &str1 , const string &str2 ){

    if( str1.size() > str2.size() )
        return true;

    if( str1.size() < str2.size() )
        return false;

    for( int i = str1.size() - 1 ; i >= 0 ; i -- ){
        if( str1[i] > str2[i] )
            return true;

        if( str1[i] < str2[i] )
            return false;
    }

    return false;
}

int main( void ){

    char enter;
    char input[10];
    int t;

    dp[0] = "0";
    initPow2();
    memset( win , -1 ,sizeof( win ) );

    scanf("%d%c",&n,&enter);
    for( int i = 1 ; i <= n ; i ++ ){
        scanf("%s%c%d%c",input,&enter,&t,&enter);

        if( input[0] == 'w' ){
            win[ t ] = i;
            dp[i] = dp[i-1];
        }
        else{

            if( win[t] != -1 ){
                string temp = pow2[ t ];
                add( temp , dp[ win[t]-1 ] );

                if( larger( temp , dp[i-1] ) )
                    dp[i] = temp;
                else
                    dp[i] = dp[i-1];
            }
            else
                dp[i] = dp[i-1];
        }
    }

    reverse( dp[n].begin() , dp[n].end() );
    printf("%s\n",dp[n].c_str());

    //system("pause");

    return 0;
}


#include <cstdio>
#include <cstring>

#include <vector>
#include <string>
#include <algorithm>

using namespace std;

typedef struct Event{

    char type;
    int x;
    bool flag;
}E;

E e[5001];
int n;
vector<int> res;
string pow2[2001];

bool canSell( int x ){

    int sellPos;
    for( sellPos = n ; sellPos >= 0 ; sellPos -- )
        if( e[sellPos].type == 's' && e[sellPos].x == x )
            break;

    if( sellPos < 0 )
        return false;

    int i;
    for( i = sellPos; i >= 0 && e[i].flag == false ; i -- )
        if( e[i].type == 'w' && e[i].x == x )
            break;

    if( e[i].flag )
        return false;

    for( int j = sellPos ; j >= i ; j -- )
        e[j].flag = true;

    for( int j = i-1 ; e[j].type == 'w' ; j -- )
        e[j].flag = true;

    return true;
}

void multi2( string &ress , const string &p ){

    int flag = 0;
    ress = "";
    for( int i = 0 ; i < p.size() ; i ++ ){
        ress += ( ( p[i] - '0' ) * 2 + flag ) % 10 + '0';
        flag = ( ( p[i] - '0' ) * 2 + flag ) / 10;
    }

    if( flag )
        ress += '1';

    return;
}

void initPow2( void ){

    pow2[0] = "1";
    for( int i = 1; i <= 2000 ; i ++ )
        multi2( pow2[i] , pow2[i-1] );

    return;
}

void add( string &ress , string num ){

    while( ress.size() < num.size() )
        ress.push_back( '0' );

    while( num.size() < ress.size() )
        num.push_back( '0' );

    int flag = 0;
    for( int i = 0 ; i < ress.size() ; i ++ ){

        ress[i] = ( ress[i] - '0' + num[i] - '0' + flag ) % 10 + '0';
        flag = ( ress[i] - '0' + num[i] - '0' + flag ) / 10;
    }

    if( flag )
        ress += '1';

    return;
}

int main( void ){

    char enter;
    char input[10];

    e[0].type = 's';
    e[0].x = 0;
    e[0].flag = true;

    scanf("%d%c",&n,&enter);
    for( int i = 1 ; i <= n ; i ++ ){
        scanf("%s%c%d%c",input,&enter,&e[i].x,&enter);
        e[i].type = input[0];
        e[i].flag = false;
    }

    res.clear();
    for( int i = 2000 ; i >= 0 ; i -- )
        if( canSell( i ) )
            res.push_back( i );

    //for( int i = 0 ; i < res.size() ; i ++ )
    //  printf("%d\n",res[i]);

    initPow2();
    string resStr = pow2[ res[0] ];
    for( int i = 1 ; i < res.size() ; i ++ )
        add( resStr , pow2[ res[i] ] );

    reverse( resStr.begin() , resStr.end() );
    printf("%s\n",resStr.c_str());

    //system("pause");

    return 0;
}


#include <cstdio>
#include <cstring>

#include <vector>
#include <string>
#include <algorithm>

using namespace std;

typedef struct Event{

    char type;
    int x;
    bool flag;
}E;

E e[5001];
int n;
vector<int> res;
string pow2[2001];

bool canSell( int x ){

    int sellPos;
    for( sellPos = n ; sellPos >= 0 ; sellPos -- )
        if( e[sellPos].type == 's' && e[sellPos].x == x )
            break;

    if( sellPos < 0 )
        return false;

    int i;
    for( i = sellPos; i >= 0 && e[i].flag == false ; i -- )
        if( e[i].type == 'w' && e[i].x == x )
            break;

    if( e[i].flag )
        return false;

    for( int j = sellPos ; j >= i ; j -- )
        e[j].flag = true;

    for( int j = i-1 ; e[j].type == 'w' ; j -- )
        e[j].flag = true;

    return true;
}

void multi2( string &ress , const string &p ){

    int flag = 0;
    ress = "";
    for( int i = 0 ; i < p.size() ; i ++ ){
        ress += ( ( p[i] - '0' ) * 2 + flag ) % 10 + '0';
        flag = ( ( p[i] - '0' ) * 2 + flag ) / 10;
    }

    if( flag )
        ress += '1';

    return;
}

void initPow2( void ){

    pow2[0] = "1";
    for( int i = 1; i <= 2000 ; i ++ )
        multi2( pow2[i] , pow2[i-1] );

    return;
}

void add( string &ress , string num ){

    while( ress.size() < num.size() )
        ress.push_back( '0' );

    while( num.size() < ress.size() )
        num.push_back( '0' );

    int flag = 0;
    for( int i = 0 ; i < ress.size() ; i ++ ){

        ress[i] = ( ress[i] - '0' + num[i] - '0' + flag ) % 10 + '0';
        flag = ( ress[i] - '0' + num[i] - '0' + flag ) / 10;
    }

    if( flag )
        ress += '1';

    return;
}

int main( void ){

    char enter;
    char input[10];

    e[0].type = 's';
    e[0].x = -1;
    e[0].flag = true;

    scanf("%d%c",&n,&enter);
    for( int i = 1 ; i <= n ; i ++ ){
        scanf("%s%c%d%c",input,&enter,&e[i].x,&enter);
        e[i].type = input[0];
        e[i].flag = false;
    }

    res.clear();
    for( int i = 2000 ; i >= 0 ; i -- )
        if( canSell( i ) )
            res.push_back( i );

    if( res.size() == 0 )
        printf("0\n");
    else{
        initPow2();
        string resStr = pow2[ res[0] ];
        for( int i = 1 ; i < res.size() ; i ++ )
            add( resStr , pow2[ res[i] ] );

        reverse( resStr.begin() , resStr.end() );
        printf("%s\n",resStr.c_str());
    }

    //system("pause");

    return 0;
}


#include <cstdio>
#include <cstring>

#include <vector>
#include <string>
#include <algorithm>

using namespace std;

string dp[5001];
int win[2001];
int n;

string pow2[2001];

void multi2( string &ress , const string &p ){

    int flag = 0;
    ress = "";
    for( int i = 0 ; i < p.size() ; i ++ ){
        ress += ( ( p[i] - '0' ) * 2 + flag ) % 10 + '0';
        flag = ( ( p[i] - '0' ) * 2 + flag ) / 10;
    }

    if( flag )
        ress += '1';

    //int pos = ress.size() - 1;
    //for( ; pos >= 0 && ress[pos] == '0' ; pos -- );
    //ress = ress.substr( 0 , pos + 1 );

    if( ress == "" )
        ress = "0";

    return;
}

void initPow2( void ){

    pow2[0] = "1";
    for( int i = 1; i <= 2000 ; i ++ )
        multi2( pow2[i] , pow2[i-1] );

    return;
}

void add( string &ress , string num ){

    while( ress.size() < num.size() )
        ress += '0';

    while( num.size() < ress.size() )
        num += '0';

    int flag = 0;
    for( int i = 0 ; i < ress.size() ; i ++ ){
        char tRes = ( ress[i] - '0' + num[i] - '0' + flag ) % 10 + '0';
        flag = ( ress[i] - '0' + num[i] - '0' + flag ) / 10;

        ress[i] = tRes;
    }

    if( flag )
        ress += '1';

    //int pos = ress.size() - 1;
    //for( ; pos >= 0 && ress[pos] == '0' ; pos -- );
    //ress = ress.substr( 0 , pos + 1 );

    if( ress == "" )
        ress = "0";

    return;
}

bool larger( const string &str1 , const string &str2 ){

    if( str1.size() > str2.size() )
        return true;

    if( str1.size() < str2.size() )
        return false;

    for( int i = str1.size() - 1 ; i >= 0 ; i -- ){
        if( str1[i] > str2[i] )
            return true;

        if( str1[i] > str2[i] )
            return false;
    }

    return false;
}

int main( void ){

    char enter;
    char input[10];
    int t;

    dp[0] = "0";
    initPow2();
    memset( win , -1 ,sizeof( win ) );

    scanf("%d%c",&n,&enter);
    for( int i = 1 ; i <= n ; i ++ ){
        scanf("%s%c%d%c",input,&enter,&t,&enter);

        if( input[0] == 'w' ){
            win[ t ] = i;
            dp[i] = dp[i-1];
        }
        else{

            if( win[t] != -1 ){
                string temp = pow2[ t ];
                add( temp , dp[ win[t]-1 ] );

                if( larger( temp , dp[i-1] ) )
                    dp[i] = temp;
                else
                    dp[i] = dp[i-1];
            }
            else
                dp[i] = dp[i-1];
        }
    }

    reverse( dp[n].begin() , dp[n].end() );
    printf("%s\n",dp[n].c_str());

    //system("pause");

    return 0;
}


#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cmath>
#include <cctype>

#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <list>
#include <iterator>
#include <functional>

using namespace std;

template<typename T> struct Point
{
        T x, y; Point(){} Point(T xx, T yy): x(xx), y(yy){}
        bool operator ==(const Point<T> &p2)
        {
                return x == p2.x && y == p2.y;
        }
        bool operator !=(const Point<T> &p2)
        {
                return x != p2.x || y != p2.y;
        }
        bool operator <(const Point<T> &p2)
        {
                return x < p2.x || x == p2.x && y < p2.y;
        }
        Point<T> operator +(const Point<T> &p2)
        {
                return Point<T>(x + p2.x, y + p2.y);
        }
        Point<T> operator -(const Point<T> &p2)
        {
                return Point<T>(x - p2.x, y - p2.y);
        }
};

#define mp make_pair
#define pb push_back
#define forlr(i, l, r) for(int (i)=(l); (i)<(r); (i)++)
#define forn(i, n) forlr(i, 0, n)
#define forit(it, c) for(__typeof((c).begin()) it = (c).begin(); it!=(c).end(); it++)
#define all(x) x.begin(), x.end()
#define zero(a) memset(a, 0, sizeof(a))

typedef long long ll;
typedef vector<int> vint;
typedef Point<int> pint;

struct BigInt
{
	string s;
	BigInt(){}
	BigInt(int a)
	{
		while(a>0)
		{
			s.pb(a%10);
			a/=10;
		}
		if (a==0)
			s.pb(0);
	}
	string ToOut()
	{
		string t;
		forn(i, s.size())
			t.push_back(s[i]+'0');
		reverse(all(t));
		return t;
	}
};
void Plus(BigInt &a, BigInt &b, BigInt &c)
{
	c.s = "";
	int ost=0;
	for (int i=0; i<min(a.s.size(), b.s.size()); i++)
	{
		c.s.pb((a.s[i]+b.s[i]+ost)%10);
		ost = (a.s[i]+b.s[i]+ost)/10;
	}
	for (int i=min(a.s.size(), b.s.size()); i<a.s.size(); i++)
	{
		c.s.pb((a.s[i]+ost)%10);
		ost = (a.s[i]+ost)/10;
	}
	for (int i=min(a.s.size(), b.s.size()); i<b.s.size(); i++)
	{
		c.s.pb((b.s[i]+ost)%10);
		ost = (b.s[i]+ost)/10;
	}
	if (ost!=0)
		c.s.pb(ost);
}

const int MAXN = 2011;

bool operator <(const bitset<MAXN> &b1, const bitset<MAXN> &b2)
{
	for(int i=MAXN-1; i>=0; --i)
	{
		if (b1[i]<b2[i])
			return true;
		if (b1[i]>b2[i])
			return false;
	}
	return false;
}

vector< bitset<MAXN> > bs;
vector< pint > v;
int main()
{
	int n, x;
	cin >> n;
	string ts;

	v.resize(n);
	bs.resize(n);

	forn(i, n)
	{
		cin >> ts >> x;
		v[i].x = x; v[i].y = -1;
		if (ts[0] == 's')
		{
			for(int j=i-1; j>=0; --j)
			{
				if (v[j].x == x)
				{
					v[i].y = j;
					break;
				}
			}
		}
	}

	bs[0].reset();
	for(int i=1; i<n; ++i)
	{
		if (v[i].y == -1)
		{
			bs[i] = bs[i-1];
			continue;
		}
		bs[i] = bs[v[i].y];
		bs[i][v[i].x] = 1;

		if (bs[i]<bs[i-1])
		{
			bs[i] = bs[i-1];
		}
	}

	BigInt res = BigInt(0), buf, two = BigInt(1);
	forn(i, MAXN)
	{
		if (bs[n-1][i])
		{
			Plus(res, two, buf);
			res = buf;
		}
		Plus(two, two, buf);
		two = buf;
	}
	cout << res.ToOut();

	return 0;
}
/*

*/


//#define MYDEBUG
//#pragma comment(linker, "/STACK:33554432")
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <functional>

#define MOD 1000000000
#define INF 1000000001
#define EPS 1e-6
#define HASH_POW 37
const double PI = acos(-1.0);

using namespace std;

int win[2010];
int sell[2010];
bool u[5010];

struct longnum
{
	int d[1000];
	int len;
};

longnum sum(longnum &a, longnum &b)
{
	longnum c;
	memset(c.d, 0, sizeof c.d);
	c.len = max(a.len, b.len);
	int sum = 0, carry = 0;
	for (int i = 0; i < max(a.len, b.len); ++i)
	{
		sum = a.d[i] + b.d[i] + carry;
		c.d[i] = sum % MOD;
		carry = sum / MOD;
	}
	if (carry)
		c.d[c.len++] = carry;
	return c;
}

longnum multi(longnum &a)
{
	longnum b;
	memset(b.d, 0, sizeof b.d);
	b.len = a.len;
	int sum = 0, carry = 0;
	for (int i = 0; i < a.len; ++i)
	{
		sum = a.d[i]*2 + carry;
		b.d[i] = sum % MOD;
		carry = sum / MOD;
	}
	if (carry)
		b.d[b.len++] = carry;
	return b;
}

void print(longnum &a)
{
	printf("%d", a.d[a.len - 1]);
	for (int i = a.len - 2; i >= 0; --i)
		printf("%.09d", a.d[i]);
}

int main()
{
	//cin.sync_with_stdio(0);
	#ifdef MYDEBUG
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
	#else
	//freopen("weakconn.in", "rt", stdin);
	//freopen("weakconn.out", "wt", stdout);
	#endif

	int n;
	scanf("%d\n", &n);
	for (int i = 1; i <= n; ++i)
	{
		char s[5];
		int x;
		scanf("%s %d\n", s, &x);
		if (strcmp(s, "win") == 0)
		{
			if (!sell[x])
				win[x] = i;
		}
		else
		{
			sell[x] = i;
		}
	}
	longnum res;
	memset(res.d, 0, sizeof res.d);
	res.len = 1;
	for (int i = 2000; i >= 0; --i)
	{
		if (win[i] && sell[i])
		{
			bool can = true;
			for (int j = win[i]; j <= sell[i]; ++j)
			{
				if (u[j])
				{
					can = false;
					break;
				}
			}
			if (can)
			{
				for (int j = win[i]; j <= sell[i]; ++j)
					u[j] = true;
				longnum tmp;
				memset(tmp.d, 0, sizeof tmp.d);
				tmp.d[0] = 1;
				tmp.len = 1;
				for (int r = 0; r < i; ++r)
					tmp = multi(tmp);
				res = sum(res, tmp);
			}
		}
	}
	print(res);

	#ifdef MYDEBUG
		cout << "\nTime = " << fixed << setprecision(3) << double(clock()) / CLOCKS_PER_SEC << endl;
	#endif
	return 0;
}


#include <stdio.h>
#include <math.h>
#include <iostream>
#include <string>
using namespace std;

int wb[5001][2];

string optval[5001];
string twopow[5001];

string multwo(string x)
{
	int carry=0;
	string retx="";
	for(int i=0;i<x.size();i++)
	{
		retx.push_back('0'+(carry+(x[i]-'0')*2)%10);
		carry=(carry+(x[i]-'0')*2)/10;

	}
	if(carry!=0)
		retx.push_back(carry+'0');
	return retx;

}

string sumstring(string a,string b)
{

	string c="";
	int carry=0;
	for(int i=0;i<max(a.size(),b.size());i++)
	{
		char as,bs;
		if(i>=a.size())
			as='0';
		else
			as=a[i];
		if(i>=b.size())
			bs='0';
		else
			bs=b[i];
		c.push_back(((as-'0')+(bs-'0')+carry)%10+'0');
		carry=(carry+as-'0'+bs-'0')/10;
	}
	if(carry>0)
		c.push_back(carry+'0');

	return c;
}

string smax(string a,string b)
{
	if(a.size()>b.size())
		return a;
	if(b.size()>a.size())
		return b;

	for(int i=a.size()-1;i>=0;i--)
	{
		if(a[i]>b[i])
			return a;
		if(a[i]<b[i])
			return b;
	}
	return a;

}

string reverse(string x)
{
	string xr;
	for(int i=x.size()-1;i>=0;i--)
		xr.push_back(x[i]);
	return xr;
}

int main()
{
	int n;
	scanf("%d",&n);

	twopow[0]="1";
	string curr="1";
	for(int i=1;i<=2001;i++)
	{
		curr=multwo(curr);
		twopow[i]=curr;
	}

	for(int i=1;i<=n;i++)
	{
		char tmp[5];
		scanf("%s",&tmp);
		int x;
		scanf("%d",&x);
		if(tmp[0]=='w')
		{
			wb[i][1]=x;
			wb[i][0]=0;
		}
		else
		{
			wb[i][1]=x;
			wb[i][0]=1;
		}

	}

	optval[0]="0";

	for(int i=1;i<=n;i++)
	{
		if(wb[i][0]==1)
		{
			string cand1=optval[i-1];
			string cand2="0";
			for(int j=i-1;j>=1;j--)
			{

				if(wb[j][0]==0 && wb[j][1]==wb[i][1])
				{
					cand2=sumstring(optval[j-1],twopow[wb[j][1]]);
					break;
				}
			}
			//printf("%d\n",i);
			optval[i]=smax(cand1,cand2);
			//cout << optval[i] << endl;

		}
		else
		{
			optval[i]=optval[i-1];
		}
	}

	cout << reverse(optval[n]) << endl;

}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>

#define forn(i,n) for (int i=0;i<n;i++)
#define ford(i,n) for (int i=n-1;i>=0;i--)
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define pi 3.1415926535897932
#define ll long long

using namespace std;

vector <string> s;
int cost[5000];
int pred[5000];

struct tlong{
	int m[1000];
	int size;
	tlong(){
		forn(i,1000)
			m[i]=0;
		size=1;
	}
};

int base=1000000000;

void sum(tlong &a,const tlong &b){
	a.size=max(a.size,b.size)+1;
	int k=0;
	forn(i,max(a.size,b.size)+1){
		int help=a.m[i];
		a.m[i]=(a.m[i]+b.m[i]+k) % base;
		k=(help+b.m[i]+k)/base;
	}
	while (a.m[a.size-1]==0) a.size--;
}

tlong max(tlong a,tlong b){
	if (a.size>b.size) return a;
	else if (a.size < b.size) return b;
	int help=a.size;
	ford(i,help){
		if (a.m[i]>b.m[i]) return a;
		else if (a.m[i]<b.m[i]) return b;
	}
	return a;
}

int f(int a){
	int s=0;
	while (a>0){
		s++;
		a/=10;
	}
	return s;
}

tlong d[5000];
tlong maxim[5000];
tlong c[2001];

int main(){
	//freopen ("input.txt","rt",stdin);
	//freopen ("output.txt","wt",stdout);
	int n;
	c[0].m[0]=1;
	for (int i=1;i<=2000;i++){
		sum(c[i],c[i-1]);
		sum(c[i],c[i-1]);
	}
	memset(d,0,sizeof(d));
	forn(i,5000) pred[i]=-1;
	scanf ("%d\n", &n);
	s.resize(n);
	memset(maxim,0,sizeof(maxim));
	forn(i,n){
		cin >> s[i];
		scanf ("%d\n", &cost[i]);
	}
	forn(i,n){
		if (s[i][0]=='s'){
			ford(j,i)
				if (cost[j]==cost[i] && s[j][0]=='w'){
					pred[i]=j;
					break;
				}
		}
	}
	forn(i,n){
		if (s[i][0]=='s'){
			if (pred[i]!=-1){
				sum(d[i],c[cost[pred[i]]]);
				sum(d[i],maxim[pred[i]]);
			}
		}
		if (i==0) maxim[i]=d[i];
		else maxim[i]=max(maxim[i-1],d[i]);
	}
	tlong maxx;
	forn(i,n)
		maxx=max(maxx,d[i]);
	ford(i,maxx.size){
		if (i!=0){
			forn(i,9-f(maxx.m[i]))
				printf ("0");
			printf ("%d", maxx.m[i]);
		}
		else printf ("%d", maxx.m[i]);
	}
	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>

#define forn(i,n) for (int i=0;i<n;i++)
#define ford(i,n) for (int i=n-1;i>=0;i--)
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define pi 3.1415926535897932
#define ll long long

using namespace std;

vector <string> s;
int cost[5000];
int pred[5000];

struct tlong{
	int m[1000];
	int size;
	tlong(){
		forn(i,1000)
			m[i]=0;
		size=1;
	}
};

int base=1000000000;

void sum(tlong &a,const tlong &b){
	a.size=max(a.size,b.size)+1;
	int k=0;
	forn(i,max(a.size,b.size)+1){
		int help=a.m[i];
		a.m[i]=(a.m[i]+b.m[i]+k) % base;
		k=(help+b.m[i]+k)/base;
	}
	while (a.m[a.size-1]==0) a.size--;
}

tlong max(tlong a,tlong b){
	if (a.size>b.size) return a;
	else if (a.size < b.size) return b;
	int help=a.size;
	ford(i,help){
		if (a.m[i]>b.m[i]) return a;
		else if (a.m[i]<b.m[i]) return b;
	}
	return a;
}

int f(int a){
	int s=0;
	while (a>0){
		s++;
		a/=10;
	}
	return s;
}

tlong d[5000];
tlong maxim[5000];
tlong c[2001];

int main(){
	//freopen ("input.txt","rt",stdin);
	//freopen ("output.txt","wt",stdout);
	int n;
	c[0].m[0]=1;
	for (int i=1;i<=2000;i++){
		sum(c[i],c[i-1]);
		sum(c[i],c[i-1]);
	}
	memset(d,0,sizeof(d));
	forn(i,5000) pred[i]=-1;
	scanf ("%d\n", &n);
	s.resize(n);
	memset(maxim,0,sizeof(maxim));
	forn(i,n){
		cin >> s[i];
		scanf ("%d\n", &cost[i]);
	}
	forn(i,n){
		if (s[i][0]=='s'){
			ford(j,i)
				if (cost[j]==cost[i] && s[j][0]=='w'){
					pred[i]=j;
					break;
				}
		}
	}
	forn(i,n){
		if (s[i][0]=='s'){
			if (pred[i]!=-1){
				sum(d[i],c[cost[pred[i]]]);
				sum(d[i],maxim[pred[i]]);
			}
		}
		if (i==0) maxim[i]=d[i];
		else maxim[i]=max(maxim[i-1],d[i]);
	}
	tlong maxx;
	forn(i,n)
		maxx=max(maxx,d[i]);
	ford(i,maxx.size){
		if (i!=maxx.size-1){
			forn(j,9-f(maxx.m[i]))
				printf ("0");
			printf ("%d", maxx.m[i]);
		}
		else printf ("%d", maxx.m[i]);
	}
	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>

#define forn(i,n) for (int i=0;i<n;i++)
#define ford(i,n) for (int i=n-1;i>=0;i--)
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define pi 3.1415926535897932
#define ll long long

using namespace std;

vector <string> s;
int cost[5000];
int pred[5000];

ll c(int x){
	ll s=1;
	forn(i,x)
		s*=2;
	return s;
}

ll d[5000];

int main(){
	//freopen ("input.txt","rt",stdin);
	//freopen ("output.txt","wt",stdout);
	int n;
	memset(d,0,sizeof(d));
	forn(i,5000) pred[i]=-1;
	scanf ("%d\n", &n);
	s.resize(n);
	forn(i,n){
		cin >> s[i];
		scanf ("%d\n", &cost[i]);
	}
	forn(i,n){
		if (s[i][0]=='s'){
			ford(j,i)
				if (cost[j]==cost[i] && s[j][0]=='w'){
					pred[i]=j;
					break;
				}
		}
	}
	forn(i,n){
		if (s[i][0]=='s'){
			if (pred[i]!=-1){
				d[i]+=c(cost[i]);
				ll maxx=-10000000000;
				ford(j,pred[i])
					maxx=max(maxx,d[j]);
				d[i]+=maxx;
			}
		}
	}
	ll maxx=-100;
	forn(i,n)
		maxx=max(maxx,d[i]);
	cout << maxx;
	return 0;
}


#define _CRT_SECURE_NO_DEPRECATE
#include <stdio.h>
#include <memory.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <ctime>
#include <fstream>
#include <iostream>

using namespace std;

#define CL(x) memset(x, 0, sizeof(x))

#define FOR(i, n) for (int i = 0; i < (int)(n); i++)

typedef long long LL;
typedef vector<int> vi;
typedef vector<string> VS;

string add(string a, string b)
{
	string res = a;
	if (res.size() < b.size())
		res = b;
	int t = 0;
	FOR(i, max(a.size(), b.size()))
	{
		if (i < a.size())
			t += a[i] - '0';
		if (i < b.size())
			t += b[i] - '0';
		res[i] = t % 10 + '0';
		t /= 10;
	}
	if (t)
		res.push_back('0' + t);
	return res;
}

int cmp(string a, string b)
{
	for (int i = max(a.size(), b.size()) - 1; i >= 0; i--)
	{
		char da = '0';
		if (i < a.size()) da = a[i];
		char db = '0';
		if (i < b.size()) db = b[i];
		if (da < db)
			return -1;
		if (da > db)
			return 1;
	}
	return 0;
}

string p2[2010];

string d[5010];

char f[5010];
int x[5010];

string D(int n)
{
	if (n == -1) return "0";
	if (d[n].size())
		return d[n];
	string res = "1";
	if (f[n] == 'w')
		res = D(n - 1);
	else
	{
		res = D(n - 1);
		for (int i = n - 1; i >= 0; i--)
			if (f[i] == 'w' && x[i] == x[n])
			{
				string t = add(D(i - 1), p2[x[n]]);
				if (cmp(res, t) < 0)
					res = t;
				break;
			}
	}
	d[n] = res;
	return res;
}

int main()
{
	p2[0] = "1";
	FOR(i, 2005)
		p2[i + 1] = add(p2[i], p2[i]);
	int n;
	scanf("%d", &n);
	FOR(i, n)
	{
		static char str[2010];
		scanf("%s %d", str, &x[i]);
		f[i] = str[0];
	}
	string res = D(n - 1);
	reverse(res.begin(), res.end());
	printf("%s\n", res.c_str());
	return 0;
}


#include <iostream>
#include <iomanip>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <cmath>

using namespace std;

#define N 1000000000

vector<vector<long long> > earn;

vector<long long> myMax(vector<long long> v1,vector<long long> v2)
{
    for(int i = 100-1 ; i >= 0 ; i--)
    {
        if(v1[i] > v2[i])return v1;
        else if(v1[i] < v2[i])return v2;
    }
    return v1;
}

vector<long long> myPow(long long a,int n)
{
    vector<long long> v(100,0);
    v[0] = 1;
    for(int i = 0 ; i < n ; i++)
    {
        for(int j = 0 ; j < 100 ; j++)
        {
            v[j]*=a;
        }
        long long carry = 0;
        for(int j = 0 ; j < 100 ; j++)
        {
            long long tmp = (v[j]+carry)/N;
            v[j] = (v[j]+carry)%N;
            carry = tmp;
        }
    }
    return v;
}

vector<long long> mySum(vector<long long>v1,vector<long long>v2)
{
    for(int i = 0 ; i < 100 ; i++)
    {
        v1[i]+=v2[i];
    }
    long long carry = 0;
    for(int i = 0 ; i < 100 ; i++)
    {
        long long tmp = (v1[i]+carry)/N;
        v1[i] = (v1[i]+carry)%N;
        carry = tmp;
    }
    return v1;
}
string makeString(vector<long long> v)
{
    string res = "";
    for(int i = 0 ; i < 100 ; i++)
    {
        for(int j = 0 ; j < 9 ; j++)
        {
            char c = '0'+(char)(v[i]%10);
            res += " ";
            res[res.size()-1] = c;
            v[i]/=10;
        }
    }
    reverse(res.begin(),res.end());
    for(unsigned int i = 0 ; i < res.size() ; i++)
    {
        if(res[i] != '0')return res.substr(i);
    }
    return "0";
}

int main()
{
    int n;
    cin >> n;

    vector<int> stick(2005,-1);
    earn.assign(5005,vector<long long>(100,0));

    for(int i = 1 ; i <= n ; i++)
    {
        string s;
        int x;
        cin >> s >> x;
        if(s=="win")
        {
            stick[x] = i;
            earn[i] = earn[i-1];
        }
        else if(s=="sell")
        {
            if(stick[x] != -1)earn[i] = myMax(earn[i-1],mySum(myPow(2,x),earn[stick[x]]));
            else earn[i] = earn[i-1];
        }
    }
    cout << makeString(earn[n]) << endl;
}


#include <iostream>
#include <iomanip>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <cmath>

using namespace std;

string strPow(char a,int n)
{
    string res = "1";
    res[0]=1;

    if(n%2==0 && a <= 2)return strPow(a*a,n/2);
    for(int i = 0 ; i < n ; i++)
    {
        for(int j = 0 ; j < res.size() ; j++)
        {
            res[j]=(res[j])*a;
        }

        int carry = 0;
        for(int j = 0 ; j < res.size() ; j++)
        {
            int tmp = res[j];
            res[j] = tmp%10 + carry;
            carry = tmp/10;
        }
        if(carry!=0)
        {
            res+=" ";
            res[res.size()-1]=carry;
        }
    }

    for(int i = 0 ; i < res.size() ; i++)res[i]+='0';
    return res;
}
string strAdd(string s1,string s2)
{
    string res;
    if(s1.size() > s2.size())res = s1+"0";else res = s2+"0";
    int carry = 0;
    for(unsigned int i = 0 ; i < res.size() ; i++)
    {
        int tmp=0;
        if(i < s1.size())tmp+=s1[i]-'0';
        if(i < s2.size())tmp+=s2[i]-'0';
        tmp += carry;
        res[i] = tmp%10 + '0';
        carry = tmp/10;
    }
    if(res[res.size()-1]=='0')return res.substr(0,res.size()-1);
    else return res;
}
string strMax(string s1,string s2)
{
    if(s1.size() > s2.size())return s1;
    else if(s2.size() > s1.size())return s2;
    else
    {
        for(int i = s1.size()-1 ; i >= 0 ; i--)
        {
            if(s1[i]>s2[i])return s1;
            else if(s2[i]>s1[i])return s2;
        }
    }
    return s1;
}

int main()
{
        int n;
        cin >> n;
        vector <int> stick(2001,-1);
        vector <string> dpStr;
        dpStr.assign(5005,"0");

        for(int i = 0 ; i < n ; i++)
        {
                string s;
                int tmp;
                cin >> s >> tmp;

                if(s.find("win")!=-1)
                {
                        stick[tmp]=i;
                        dpStr[i+1] = dpStr[i];
                }
                if(s.find("sell")!=-1)
                {
                    if(stick[tmp]!=-1)dpStr[i+1]=strMax(dpStr[i],strAdd(strPow(2,tmp),dpStr[stick[tmp]]));
                    else dpStr[i+1] = dpStr[i];
                }
        }

        reverse(dpStr[n].begin(),dpStr[n].end());
        cout << dpStr[n] << endl;
}


#include <iostream>
#include <iomanip>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <cmath>

using namespace std;

#define N 1000000000

vector<vector<long long> > earn;

vector<long long> myMax(vector<long long> v1,vector<long long> v2)
{
    for(int i = 100-1 ; i >= 0 ; i--)
    {
        if(v1[i] > v2[i])return v1;
        else if(v1[i] < v2[i])return v2;
    }
    return v1;
}

vector<long long> myPow(long long a,int n)
{
    vector<long long> v(100,0);
    v[0] = 1;
    for(int i = 0 ; i < n ; i++)
    {
        for(int j = 0 ; j < 100 ; j++)
        {
            v[j]*=a;
        }
        long long carry = 0;
        for(int j = 0 ; j < 100 ; j++)
        {
            long long tmp = (v[j]+carry)/N;
            v[j] = (v[j]+carry)%N;
            carry = tmp;
        }
    }
    return v;
}

vector<long long> mySum(vector<long long>v1,vector<long long>v2)
{
    for(int i = 0 ; i < 100 ; i++)
    {
        v1[i]+=v2[i];
    }
    long long carry = 0;
    for(int i = 0 ; i < 100 ; i++)
    {
        long long tmp = (v1[i]+carry)/N;
        v1[i] = (v1[i]+carry)%N;
        carry = tmp;
    }
    return v1;
}
string makeString(vector<long long> v)
{
    string res = "";
    for(int i = 0 ; i < 100 ; i++)
    {
        for(int j = 0 ; j < 9 ; j++)
        {
            char c = '0'+(char)(v[i]%10);
            res += " ";
            res[res.size()-1] = c;
            v[i]/=10;
        }
    }
    reverse(res.begin(),res.end());
    for(unsigned int i = 0 ; i < res.size() ; i++)
    {
        if(res[i] != '0')return res.substr(i);
    }
    return res;
}

int main()
{
    int n;
    cin >> n;

    vector<int> stick(2005,-1);
    earn.assign(5005,vector<long long>(100,0));

    for(int i = 1 ; i <= n ; i++)
    {
        string s;
        int x;
        cin >> s >> x;
        if(s=="win")
        {
            stick[x] = i;
            earn[i] = earn[i-1];
        }
        else if(s=="sell")
        {
            if(stick[x] != -1)earn[i] = myMax(earn[i-1],mySum(myPow(2,x),earn[stick[x]]));
            else earn[i] = earn[i-1];
        }
    }
    cout << makeString(earn[n]) << endl;
}


#include <iostream>
#include <iomanip>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <cmath>

using namespace std;

int main()
{
    long long LLMAX = 1LL << 60;
    vector<vector<long long> > dp(2005,vector<long long>(2005,LLMAX));

    int n;
    cin >> n;
    for(int i = 0 ; i < n ; i++)
    {
        int t,c;
        cin >> t >> c;
        int index;
        for(int j = 0 ; j <= n ; j++)
        {
            index = min(j+t+1,n);
            dp[i+1][j] = min(dp[i+1][j],dp[i][j]);
            dp[i+1][index] = min(dp[i+1][index],dp[i][j]+c);
        }
        index = min(t+1,n);
        dp[i+1][index] = min(dp[i+1][index],(long long)c);
    }
    cout << dp[n][n] << endl;
}


#include <iostream>
#include <iomanip>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <cmath>

using namespace std;

#define N 1000000000
#define M 72

vector<vector<long long> > earn;

vector<long long> myMax(vector<long long> v1,vector<long long> v2)
{
    for(int i = M-1 ; i >= 0 ; i--)
    {
        if(v1[i] > v2[i])return v1;
        else if(v1[i] < v2[i])return v2;
    }
    return v1;
}

vector<long long> myPow(long long a,int n)
{
    vector<long long> v(M,0);
    v[0] = 1;
    for(int i = 0 ; i < n ; i++)
    {
        for(int j = 0 ; j < M ; j++)
        {
            v[j]*=a;
        }
        long long carry = 0;
        for(int j = 0 ; j < M ; j++)
        {
            long long tmp = (v[j]+carry)/N;
            v[j] = (v[j]+carry)%N;
            carry = tmp;
        }
    }
    return v;
}

vector<long long> mySum(vector<long long>v1,vector<long long>v2)
{
    for(int i = 0 ; i < M ; i++)
    {
        v1[i]+=v2[i];
    }
    long long carry = 0;
    for(int i = 0 ; i < M ; i++)
    {
        long long tmp = (v1[i]+carry)/N;
        v1[i] = (v1[i]+carry)%N;
        carry = tmp;
    }
    return v1;
}
string makeString(vector<long long> v)
{
    string res = "";
    for(int i = 0 ; i < M ; i++)
    {
        for(int j = 0 ; j < 9 ; j++)
        {
            char c = '0'+(char)(v[i]%10);
            res += " ";
            res[res.size()-1] = c;
            v[i]/=10;
        }
    }
    reverse(res.begin(),res.end());
    for(unsigned int i = 0 ; i < res.size() ; i++)
    {
        if(res[i] != '0')return res.substr(i);
    }
    return "0";
}

int main()
{
    int n;
    cin >> n;

    vector<int> stick(2005,-1);
    earn.assign(5005,vector<long long>(M,0));

    for(int i = 1 ; i <= n ; i++)
    {
        string s;
        int x;
        cin >> s >> x;
        if(s=="win")
        {
            stick[x] = i;
            earn[i] = earn[i-1];
        }
        else if(s=="sell")
        {
            if(stick[x] != -1)earn[i] = myMax(earn[i-1],mySum(myPow(2,x),earn[stick[x]]));
            else earn[i] = earn[i-1];
        }
    }
    cout << makeString(earn[n]) << endl;
}


#include <iostream>
#include <iomanip>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <cmath>

using namespace std;

#define N 1000000000
#define M 72

vector<vector<long long> > earn;

vector<long long> myMax(vector<long long> v1,vector<long long> v2)
{
    for(int i = M-1 ; i >= 0 ; i--)
    {
        if(v1[i] > v2[i])return v1;
        else if(v1[i] < v2[i])return v2;
    }
    return v1;
}

vector<long long> myMul(vector<long long> v,long long a)
{
    for(int j = 0 ; j < M ; j++)
    {
        v[j]*=a;
    }
    long long carry = 0;
    for(int j = 0 ; j < M ; j++)
    {
        long long tmp = (v[j]+carry)/N;
        v[j] = (v[j]+carry)%N;
        carry = tmp;
    }
    return v;
}

vector<long long> myPow(long long a,int n)
{
    vector<long long> v(M,0);v[0]=1;
    if(n==0)return v;
    if(n%2 == 0 && a <= 1024)return myPow(a*a,n/2);
    return myMul(myPow(a,n-1),a);
}

vector<long long> mySum(vector<long long>v1,vector<long long>v2)
{
    for(int i = 0 ; i < M ; i++)
    {
        v1[i]+=v2[i];
    }
    long long carry = 0;
    for(int i = 0 ; i < M ; i++)
    {
        long long tmp = (v1[i]+carry)/N;
        v1[i] = (v1[i]+carry)%N;
        carry = tmp;
    }
    return v1;
}
string makeString(vector<long long> v)
{
    string res = "";
    for(int i = 0 ; i < M ; i++)
    {
        for(int j = 0 ; j < 9 ; j++)
        {
            char c = '0'+(char)(v[i]%10);
            res += " ";
            res[res.size()-1] = c;
            v[i]/=10;
        }
    }
    reverse(res.begin(),res.end());
    for(unsigned int i = 0 ; i < res.size() ; i++)
    {
        if(res[i] != '0')return res.substr(i);
    }
    return "0";
}

int main()
{
    int n;
    cin >> n;

    vector<int> stick(2005,-1);
    earn.assign(5005,vector<long long>(M,0));

    for(int i = 1 ; i <= n ; i++)
    {
        string s;
        int x;
        cin >> s >> x;
        if(s=="win")
        {
            stick[x] = i;
            earn[i] = earn[i-1];
        }
        else if(s=="sell")
        {
            if(stick[x] != -1)earn[i] = myMax(earn[i-1],mySum(myPow(2,x),earn[stick[x]]));
            else earn[i] = earn[i-1];
        }
    }
    cout << makeString(earn[n]) << endl;
}


#include <iostream>
#include <iomanip>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <cmath>

using namespace std;

#define N 1000000000
#define M 72

vector<vector<long long> > earn;

vector<long long> myMax(vector<long long> v1,vector<long long> v2)
{
    for(int i = M-1 ; i >= 0 ; i--)
    {
        if(v1[i] > v2[i])return v1;
        else if(v1[i] < v2[i])return v2;
    }
    return v1;
}

vector<long long> myMul(vector<long long> v,long long a)
{
    for(int j = 0 ; j < M ; j++)
    {
        v[j]*=a;
    }
    long long carry = 0;
    for(int j = 0 ; j < M ; j++)
    {
        long long tmp = (v[j]+carry)/N;
        v[j] = (v[j]+carry)%N;
        carry = tmp;
    }
    return v;
}

vector<long long> myPow(long long a,int n)
{
    vector<long long> v(M,0);v[0]=1;
    if(n==0)return v;
    if(n%2 == 0 && a <= 65536)return myPow(a*a,n/2);
    return myMul(myPow(a,n-1),a);
}

vector<long long> mySum(vector<long long>v1,vector<long long>v2)
{
    for(int i = 0 ; i < M ; i++)
    {
        v1[i]+=v2[i];
    }
    long long carry = 0;
    for(int i = 0 ; i < M ; i++)
    {
        long long tmp = (v1[i]+carry)/N;
        v1[i] = (v1[i]+carry)%N;
        carry = tmp;
    }
    return v1;
}
string makeString(vector<long long> v)
{
    string res = "";
    for(int i = 0 ; i < M ; i++)
    {
        for(int j = 0 ; j < 9 ; j++)
        {
            char c = '0'+(char)(v[i]%10);
            res += " ";
            res[res.size()-1] = c;
            v[i]/=10;
        }
    }
    reverse(res.begin(),res.end());
    for(unsigned int i = 0 ; i < res.size() ; i++)
    {
        if(res[i] != '0')return res.substr(i);
    }
    return "0";
}

int main()
{
    int n;
    cin >> n;

    vector<int> stick(2005,-1);
    earn.assign(5005,vector<long long>(M,0));

    for(int i = 1 ; i <= n ; i++)
    {
        string s;
        int x;
        cin >> s >> x;
        if(s=="win")
        {
            stick[x] = i;
            earn[i] = earn[i-1];
        }
        else if(s=="sell")
        {
            if(stick[x] != -1)earn[i] = myMax(earn[i-1],mySum(myPow(2,x),earn[stick[x]]));
            else earn[i] = earn[i-1];
        }
    }
    cout << makeString(earn[n]) << endl;
}


#include <iostream>
#include <iomanip>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <cmath>

using namespace std;

string strPow(int a,int n)
{
    string res = "1";
    res[0]=1;

    for(int i = 0 ; i < n ; i++)
    {
        for(int j = 0 ; j < res.size() ; j++)
        {
            res[j]=(res[j])*a;
        }

        int carry = 0;
        for(int j = 0 ; j < res.size() ; j++)
        {
            int tmp = res[j];
            res[j] = tmp%10 + carry;
            carry = tmp/10;
        }
        if(carry!=0)
        {
            res+=" ";
            res[res.size()-1]=carry;
        }
    }

    for(int i = 0 ; i < res.size() ; i++)res[i]+='0';
    return res;
}
string strAdd(string s1,string s2)
{
    string res;
    if(s1.size() > s2.size())res = s1+"0";else res = s2+"0";
    int carry = 0;
    for(unsigned int i = 0 ; i < res.size() ; i++)
    {
        int tmp=0;
        if(i < s1.size())tmp+=s1[i]-'0';
        if(i < s2.size())tmp+=s2[i]-'0';
        tmp += carry;
        res[i] = tmp%10 + '0';
        carry = tmp/10;
    }
    if(res[res.size()-1]=='0')return res.substr(0,res.size()-1);
    else return res;
}
string strMax(string s1,string s2)
{
    if(s1.size() > s2.size())return s1;
    else if(s2.size() > s1.size())return s2;
    else
    {
        for(int i = s1.size()-1 ; i >= 0 ; i--)
        {
            if(s1[i]>s2[i])return s1;
            else if(s2[i]>s1[i])return s2;
        }
    }
    return s1;
}

int main()
{
        int n;
        cin >> n;
        vector <int> stick(2001,-1);
        vector <string> dpStr;
        dpStr.assign(5005,"0");

        for(int i = 0 ; i < n ; i++)
        {
                string s;
                int tmp;
                cin >> s >> tmp;

                if(s.find("win")!=-1)
                {
                        stick[tmp]=i;
                        dpStr[i+1] = dpStr[i];
                }
                if(s.find("sell")!=-1)
                {
                    if(stick[tmp]!=-1)dpStr[i+1]=strMax(dpStr[i],strAdd(strPow(2,tmp),dpStr[stick[tmp]]));
                    else dpStr[i+1] = dpStr[i];
                }
        }

        reverse(dpStr[n].begin(),dpStr[n].end());
        cout << dpStr[n] << endl;
}


#include <iostream>
#include <iomanip>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <cmath>

using namespace std;

int main()
{
        int n;
        cin >> n;
        int now = -1;
        vector <int> stick(2001,-1);
        multiset<int> earn;
        earn.clear();
        earn.insert(-1);
        for(int i = 0 ; i < n ; i++)
        {
                string s;
                cin >> s;

                if(s.find("win")!=-1)
                {
                        int tmp;
                        cin >> tmp;
                        stick[tmp]=i;
                }
                if(s.find("sell")!=-1)
                {
                        int tmp;
                        cin >> tmp;
                        if(stick[tmp]!=-1)
                        {
                                multiset<int>::iterator it = earn.end();
                                it--;
                                if(now<stick[tmp])
                                {
                                        earn.insert(tmp);
                                        now = i;
                                }
                                else if(stick[tmp] != -1 && *it<tmp)
                                {
                                        earn.clear();
                                        earn.insert(tmp);
                                        now = i;
                                }
                        }
                }
        }

        multiset<int>::iterator it = earn.begin();

        vector <int> all(666,0);
        while(it!=earn.end())
        {
                if(*it==-1)
                {
                        it++;
                        continue;
                }
                vector<int> tmp(666,0);tmp[0]=1;
                for(int i = 0 ; i < *it ; i++)
                {
                        for(int j = 0 ; j < 666 ; j++)
                        {
                                tmp[j]*=2;
                        }
                        for(int j = 0 ; j < 666 ; j++)
                        {
                                if(tmp[j]>=10)
                                {
                                        tmp[j+1]+=tmp[j]/10;
                                        tmp[j]%=10;
                                }
                        }
                }

                for(int i = 0 ; i < 666 ; i++)
                {
                        all[i]+=tmp[i];
                        if(all[i]>=10)
                        {
                                all[i+1]+=all[i]/10;
                                all[i]%=10;
                        }
                }
                it++;
        }

        string res = "";
        string tmp = "";
        for(int i = 0 ; i < 666 ; i++)
        {
                ostringstream oss;
                oss << all[i];
                tmp += oss.str();
                if(all[i]!=0)
                {
                        res+=tmp;
                        tmp = "";
                }
        }

        if(*earn.begin()==-1 && earn.size() == 1)res="0";
        reverse(res.begin(),res.end());
        cout << res << endl;
}


#include <iostream>
#include <iomanip>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <cmath>

using namespace std;

int main()
{
        int n;
        cin >> n;
        int now = -1;
        vector <int> stick(2001,-1);
        multiset<int> earn;
        earn.clear();
        earn.insert(-1);
        for(int i = 0 ; i < n ; i++)
        {
                string s;
                cin >> s;

                if(s.find("win")!=-1)
                {
                        int tmp;
                        cin >> tmp;
                        stick[tmp]=i;
                }
                if(s.find("sell")!=-1)
                {
                        int tmp;
                        cin >> tmp;
                        if(stick[tmp]!=-1)
                        {
                                multiset<int>::iterator it = earn.end();
                                it--;
                                if(now<stick[tmp])
                                {
                                        stick[tmp]=-1;
                                        earn.insert(tmp);
                                        now = i;
                                }
                                else if(stick[tmp] != -1 && now>stick[tmp] && *it<tmp)
                                {
                                        stick[tmp]=-1;
                                        earn.clear();
                                        earn.insert(tmp);
                                        now = i;
                                }
                        }
                }
        }

        multiset<int>::iterator it = earn.begin();

        vector <int> all(666,0);
        while(it!=earn.end())
        {
                if(*it==-1)
                {
                        it++;
                        continue;
                }
                vector<int> tmp(666,0);tmp[0]=1;
                for(int i = 0 ; i < *it ; i++)
                {
                        for(int j = 0 ; j < 666 ; j++)
                        {
                                tmp[j]*=2;
                        }
                        for(int j = 0 ; j < 666 ; j++)
                        {
                                if(tmp[j]>=10)
                                {
                                        tmp[j+1]+=tmp[j]/10;
                                        tmp[j]%=10;
                                }
                        }
                }

                for(int i = 0 ; i < 666 ; i++)
                {
                        all[i]+=tmp[i];
                        if(all[i]>=10)
                        {
                                all[i+1]+=all[i]/10;
                                all[i]%=10;
                        }
                }
                it++;
        }

        string res = "";
        string tmp = "";
        for(int i = 0 ; i < 666 ; i++)
        {
                ostringstream oss;
                oss << all[i];
                tmp += oss.str();
                if(all[i]!=0)
                {
                        res+=tmp;
                        tmp = "";
                }
        }

        if(*earn.begin()==-1 && earn.size() == 1)res="0";
        reverse(res.begin(),res.end());
        cout << res << endl;
}


#include <iostream>
#include <iomanip>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <cmath>

using namespace std;

#define N 1000000000
#define M 72

vector<vector<long long> > earn;

vector<long long> myMax(vector<long long> v1,vector<long long> v2)
{
    for(int i = M-1 ; i >= 0 ; i--)
    {
        if(v1[i] > v2[i])return v1;
        else if(v1[i] < v2[i])return v2;
    }
    return v1;
}

vector<long long> myMul(vector<long long> v,long long a)
{
    for(int j = 0 ; j < M ; j++)
    {
        v[j]*=a;
    }
    long long carry = 0;
    for(int j = 0 ; j < M ; j++)
    {
        long long tmp = (v[j]+carry)/N;
        v[j] = (v[j]+carry)%N;
        carry = tmp;
    }
    return v;
}

vector<long long> myPow(long long a,int n)
{
    vector<long long> v(M,0);v[0]=1;
    if(n==0)return v;
    if(n%2 == 0 && a <= 256)return myPow(a*a,n/2);
    return myMul(myPow(a,n-1),a);
}

vector<long long> mySum(vector<long long>v1,vector<long long>v2)
{
    for(int i = 0 ; i < M ; i++)
    {
        v1[i]+=v2[i];
    }
    long long carry = 0;
    for(int i = 0 ; i < M ; i++)
    {
        long long tmp = (v1[i]+carry)/N;
        v1[i] = (v1[i]+carry)%N;
        carry = tmp;
    }
    return v1;
}
string makeString(vector<long long> v)
{
    string res = "";
    for(int i = 0 ; i < M ; i++)
    {
        for(int j = 0 ; j < 9 ; j++)
        {
            char c = '0'+(char)(v[i]%10);
            res += " ";
            res[res.size()-1] = c;
            v[i]/=10;
        }
    }
    reverse(res.begin(),res.end());
    for(unsigned int i = 0 ; i < res.size() ; i++)
    {
        if(res[i] != '0')return res.substr(i);
    }
    return "0";
}

int main()
{
    int n;
    cin >> n;

    vector<int> stick(2005,-1);
    earn.assign(5005,vector<long long>(M,0));

    for(int i = 1 ; i <= n ; i++)
    {
        string s;
        int x;
        cin >> s >> x;
        if(s=="win")
        {
            stick[x] = i;
            earn[i] = earn[i-1];
        }
        else if(s=="sell")
        {
            if(stick[x] != -1)earn[i] = myMax(earn[i-1],mySum(myPow(2,x),earn[stick[x]]));
            else earn[i] = earn[i-1];
        }
    }
    cout << makeString(earn[n]) << endl;
}


#include <iostream>
#include <iomanip>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <cmath>

using namespace std;

#define N 1000000000
#define M 72

vector<vector<long long> > earn;

vector<long long> myMax(vector<long long> v1,vector<long long> v2)
{
    for(int i = M-1 ; i >= 0 ; i--)
    {
        if(v1[i] > v2[i])return v1;
        else if(v1[i] < v2[i])return v2;
    }
    return v1;
}

vector<long long> myMul(vector<long long> v,long long a)
{
    for(int j = 0 ; j < M ; j++)
    {
        v[j]*=a;
    }
    long long carry = 0;
    for(int j = 0 ; j < M ; j++)
    {
        long long tmp = (v[j]+carry)/N;
        v[j] = (v[j]+carry)%N;
        carry = tmp;
    }
    return v;
}

vector<long long> myPow(long long a,int n)
{
    vector<long long> v(M,0);v[0]=1;
    if(n==0)return v;
    if(n%2 == 0 && a <= 128)return myPow(a*a,n/2);
    return myMul(myPow(a,n-1),a);
}

vector<long long> mySum(vector<long long>v1,vector<long long>v2)
{
    for(int i = 0 ; i < M ; i++)
    {
        v1[i]+=v2[i];
    }
    long long carry = 0;
    for(int i = 0 ; i < M ; i++)
    {
        long long tmp = (v1[i]+carry)/N;
        v1[i] = (v1[i]+carry)%N;
        carry = tmp;
    }
    return v1;
}
string makeString(vector<long long> v)
{
    string res = "";
    for(int i = 0 ; i < M ; i++)
    {
        for(int j = 0 ; j < 9 ; j++)
        {
            char c = '0'+(char)(v[i]%10);
            res += " ";
            res[res.size()-1] = c;
            v[i]/=10;
        }
    }
    reverse(res.begin(),res.end());
    for(unsigned int i = 0 ; i < res.size() ; i++)
    {
        if(res[i] != '0')return res.substr(i);
    }
    return "0";
}

int main()
{
    int n;
    cin >> n;

    vector<int> stick(2005,-1);
    earn.assign(5005,vector<long long>(M,0));

    for(int i = 1 ; i <= n ; i++)
    {
        string s;
        int x;
        cin >> s >> x;
        if(s=="win")
        {
            stick[x] = i;
            earn[i] = earn[i-1];
        }
        else if(s=="sell")
        {
            if(stick[x] != -1)earn[i] = myMax(earn[i-1],mySum(myPow(2,x),earn[stick[x]]));
            else earn[i] = earn[i-1];
        }
    }
    cout << makeString(earn[n]) << endl;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stdio.h>
#include <cmath>
#include <string>
using namespace std;

vector<int> A;
set<int> B;

vector<int> refs;
void Rec(int l, int r)
  {
  if (l>=r) return;

  refs.assign(3001,-1);
  int mx=-1,left,right;
  for(int i=l;i<=r;++i)
    {
    if (A[i]>0) refs[A[i]]=i;
    if (A[i]<0 && refs[-A[i]]!=-1)
      {
      if (mx==-1 || -A[i]>mx) {mx=-A[i];left=refs[-A[i]];right=i;}
      }
    }
  if (mx==-1) return;

  Rec(l,left-1);Rec(right+1,r);
  B.insert(mx);
  }

void Add(std::vector<int> &S, std::vector<int> &D)
  {
  int i=0,c=0;
  while(i<D.size()||i<S.size()||c)
    {
    int ad=0;
    if (i<D.size()) ad=D[i];
    if (i<S.size()) S[i]=S[i]+ad+c; else {S.push_back((ad+c)%10);c=(ad+c)/10;++i;continue;}
    c=S[i]/10;
    S[i]=S[i]%10;
    ++i;
    }
  }

void Mult(std::vector<int> &D, int t)
  {
  int i=0,c=0;
  while(i<D.size()||c)
    {
    if (i<D.size()) D[i]=D[i]*t+c; else {D.push_back(c%10);c/=10;++i;continue;}
    c=D[i]/10;
    D[i]=D[i]%10;
    ++i;
    }
  }

int main()
  {
  int n;
  cin >> n;
  for(int i=0;i<n;++i)
    {
    string s;
    int x;
    cin >> s >> x;
    if (s=="win") A.push_back(x); else A.push_back(-x);
    }

  Rec(0,n-1);

  std::vector<int> D(1,1);
  std::vector<int> S(1,0);
  for(int i=0;i<=3000;++i)
    {
    if (B.find(i)!=B.end())
      Add(S,D);
    Mult(D,2);
    }

  for(int i=S.size()-1;i>=0;--i) cout << S[i];
  return 0;
  }


#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stdio.h>
#include <cmath>
#include <string>
using namespace std;

vector<int> A;
set<int> B;

vector<int> refs;
void Rec(int l, int r)
  {
  if (l>=r) return;

  refs.assign(3001,-1);
  int mx=-1,left,right;
  for(int i=l;i<=r;++i)
    {
    if (A[i]>0) refs[A[i]]=i;
    if (A[i]<0 && refs[-A[i]]!=-1)
      {
      if (mx==-1 || -A[i]>mx) {mx=-A[i];left=refs[-A[i]];right=i;}
      }
    }
  if (mx==-1) return;

  Rec(l,left-1);Rec(right+1,r);
  B.insert(mx);
  }

void Add(std::vector<int> &S, std::vector<int> &D)
  {
  int i=0,c=0;
  while(i<D.size()||i<S.size()||c)
    {
    int ad=0;
    if (i<D.size()) ad=D[i];
    if (i<S.size()) S[i]=S[i]+ad+c; else {S.push_back((ad+c)%10);c=(ad+c)/10;++i;continue;}
    c=S[i]/10;
    S[i]=S[i]%10;
    ++i;
    }
  }

void Mult(std::vector<int> &D, int t)
  {
  int i=0,c=0;
  while(i<D.size()||c)
    {
    if (i<D.size()) D[i]=D[i]*t+c; else {D.push_back(c%10);c/=10;++i;continue;}
    c=D[i]/10;
    D[i]=D[i]%10;
    ++i;
    }
  }

int main()
  {
  int n;
  cin >> n;
  for(int i=0;i<n;++i)
    {
    string s;
    int x;
    cin >> s >> x;
    if (s=="win") A.push_back(x); else A.push_back(-x);
    }

  Rec(0,n-1);

  std::vector<int> D(1,1);
  std::vector<int> S(1,0);
  for(int i=1;i<=3000;++i)
    {
    Mult(D,2);
    if (B.find(i)!=B.end())
      Add(S,D);
    }

  for(int i=S.size()-1;i>=0;--i) cout << S[i];
  return 0;
  }


#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stdio.h>
#include <cmath>
#include <string>
using namespace std;

vector<int> A;
set<int> B;

vector<int> refs;
void Rec(int l, int r)
  {
  if (l>=r) return;

  refs.assign(3001,-1);
  int mx=-1,left,right;
  for(int i=l;i<=r;++i)
    {
    if (A[i]>0) refs[A[i]]=i;
    if (A[i]<0 && refs[-A[i]]!=-1)
      {
      if (mx==-1 || -A[i]>mx) {mx=-A[i];left=refs[-A[i]];right=i;}
      }
    }
  if (mx==-1) return;

  Rec(l,left-1);Rec(right+1,r);
  B.insert(mx);
  }

void Add(std::vector<int> &S, std::vector<int> &D)
  {
  int i=0,c=0;
  while(i<D.size()||i<S.size()||c)
    {
    int ad=0;
    if (i<D.size()) ad=D[i];
    if (i<S.size()) S[i]=S[i]+ad+c; else {S.push_back((ad+c)%10);c=(ad+c)/10;++i;continue;}
    c=S[i]/10;
    S[i]=S[i]%10;
    ++i;
    }
  }

void Mult(std::vector<int> &D, int t)
  {
  int i=0,c=0;
  while(i<D.size()||c)
    {
    if (i<D.size()) D[i]=D[i]*t+c; else {D.push_back(c%10);c/=10;++i;continue;}
    c=D[i]/10;
    D[i]=D[i]%10;
    ++i;
    }
  }

int main()
  {
  int n;
  cin >> n;
  for(int i=0;i<n;++i)
    {
    string s;
    int x;
    cin >> s >> x;
    if (s=="win") A.push_back(x); else A.push_back(-x);
    }

  Rec(0,n-1);

  std::vector<int> D(1,1);
  std::vector<int> S(1,0);
  for(int i=1;i<=2000;++i)
    {
    Mult(D,2);
    if (B.find(i)!=B.end())
      Add(S,D);
    }

  for(int i=S.size()-1;i>=0;--i) cout << S[i];
  return 0;
  }


#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stdio.h>
#include <cmath>
#include <string>
using namespace std;

vector<int> A;
set<int> B;

vector<int> refs;
void Rec(int l, int r)
  {
  if (l>=r) return;

  refs.assign(3001,-1);
  int mx=-1,left,right;
  for(int i=l;i<=r;++i)
    {
    if (A[i]>0) refs[A[i]]=i;
    if (A[i]<0 && refs[-A[i]]!=-1)
      {
      if (mx==-1 || -A[i]>mx) {mx=-A[i];left=refs[-A[i]];right=i;}
      }
    }
  if (mx==-1) return;

  Rec(l,left-1);Rec(right+1,r);
  B.insert(mx);
  }

void Add(std::vector<int> &S, std::vector<int> &D)
  {
  int i=0,c=0;
  while(i<D.size()||i<S.size()||c)
    {
    int ad=0;
    if (i<D.size()) ad=D[i];
    if (i<S.size()) S[i]=S[i]+ad+c; else {S.push_back((ad+c)%10);c=(ad+c)/10;++i;continue;}
    c=S[i]/10;
    S[i]=S[i]%10;
    ++i;
    }
  }

void Mult(std::vector<int> &D, int t)
  {
  int i=0,c=0;
  while(i<D.size()||c)
    {
    if (i<D.size()) D[i]=D[i]*t+c; else {D.push_back(c%10);c/=10;++i;continue;}
    c=D[i]/10;
    D[i]=D[i]%10;
    ++i;
    }
  }

int main()
  {
  int n;
  cin >> n;
  for(int i=0;i<n;++i)
    {
    string s;
    int x;
    cin >> s >> x;
    if (s=="win") A.push_back(x);
    if (s=="sell") A.push_back(-x);
    }

  Rec(0,n-1);

  std::vector<int> D(1,1);
  std::vector<int> S(1,0);
  for(int i=0;i<=3000;++i)
    {
    if (B.find(i)!=B.end())
      Add(S,D);
    Mult(D,2);
    }

  for(int i=S.size()-1;i>=0;--i) cout << S[i];
  return 0;
  }


#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stdio.h>
#include <cmath>
#include <string>
using namespace std;

vector<int> A,E;
set<int> B;

vector<int> refs;
void Rec(int l, int r)
  {
  if (l>=r) return;

  refs.assign(3001,-1);
  int mx=-1,left,right;
  for(int i=l;i<=r;++i)
    {
    if (E[i]>0) refs[A[i]]=i;
    if (E[i]<0 && refs[A[i]]!=-1)
      {
      if (mx==-1 || A[i]>mx) {mx=A[i];left=refs[A[i]];right=i;}
      }
    }
  if (mx==-1) return;

  Rec(l,left-1);Rec(right+1,r);
  B.insert(mx);
  }

void Add(std::vector<int> &S, std::vector<int> &D)
  {
  int i=0,c=0;
  while(i<D.size()||i<S.size()||c)
    {
    int ad=0;
    if (i<D.size()) ad=D[i];
    if (i<S.size()) S[i]=S[i]+ad+c; else {S.push_back((ad+c)%10);c=(ad+c)/10;++i;continue;}
    c=S[i]/10;
    S[i]=S[i]%10;
    ++i;
    }
  }

void Mult(std::vector<int> &D, int t)
  {
  int i=0,c=0;
  while(i<D.size()||c)
    {
    if (i<D.size()) D[i]=D[i]*t+c; else {D.push_back(c%10);c/=10;++i;continue;}
    c=D[i]/10;
    D[i]=D[i]%10;
    ++i;
    }
  }

int main()
  {
  int n;
  cin >> n;
  for(int i=0;i<n;++i)
    {
    string s;
    int x;
    cin >> s >> x;
    if (s=="win") {A.push_back(x);E.push_back(1);}
    if (s=="sell") {A.push_back(x);E.push_back(-1);}
    }

  Rec(0,n-1);

  std::vector<int> D(1,1);
  std::vector<int> S(1,0);
  for(int i=0;i<=3000;++i)
    {
    if (B.find(i)!=B.end())
      Add(S,D);
    Mult(D,2);
    }

  for(int i=S.size()-1;i>=0;--i) cout << S[i];
  return 0;
  }


#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_DEPRECATE

#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#pragma comment(linker, "/STACK:64000000")

template<class T> inline T sqr (T x) {return x * x;}

typedef long long int64;
typedef unsigned long long uint64;
typedef pair<int, int> pii;
typedef pair<int64, int64> pii64;
typedef pair<double, double> pdd;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
#define eps  1e-8
#define inf  0x7f7f7f7f
#define sfind(S, C) int((S).find(C))
#define sz(C) (int)((C).size())
#define all(C) (C).begin(), (C).end()
#define TASK "test"
#define RR 151

char used[1 << 13] = {0};
int pos[1 << 11];

struct bigint {
    static const int base = 1000*1000*1000;
    int n;
    int a[128];
    bigint () {
        n = 1;
        memset(a, 0, sizeof a);
    }
    bigint (int t) {
        n = 1;
        memset(a, 0, sizeof a);
        a[0] = t;
    }
    void operator *= (int b) {
        for (int i = 0, carry = 0; i < n || carry; ++i) {
            if (i == n) ++n;
            int64 cur = carry + a[i] * 1ll * b;
            carry = int(cur / base);
            a[i] = int(cur - carry * 1ll * base);
        }
    }
    void operator += (const bigint &b) {
        for (int i = 0, carry = 0; i < max(n, b.n) || carry; ++i) {
            if (i == n) ++n;
            a[i] += carry + (i < b.n ? b.a[i] : 0);
            carry = a[i] >= base;
            if (carry) a[i] -= base;
        }
    }
    void print() {
        printf("%d", a[n - 1]);
        for (int i = n - 2; i >= 0; --i)
            printf("%09d", a[i]);
    }
};

bigint pp[1 << 11];

int main() {
#ifndef ONLINE_JUDGE
    freopen(TASK ".in", "r", stdin);
    freopen(TASK ".out", "w", stdout);
#endif

    int T;
    scanf("%d\n", &T);
    char op[8];
    vector<int> ans;
    vector<pii> act;
    memset(pos, -1, sizeof pos);
    for (int x; T--; ) {
        scanf("%s%d", op, &x);
        if (op[0] == 's')
            pos[x] = sz(act);
        act.push_back(pii(op[0], x));
    }
    for (int i = 2000; i >= 0; --i) {
        if (pos[i] == -1) continue;
        for (int j = pos[i] - 1; j >= 0; --j) {
            if (used[j]) break;
            if (act[j].first == 'w' && act[j].second == i) {
                ans.push_back(i);
                for (int k = j; k >= 0 && act[k].first == 'w'; --k)
                    used[k] = true;
                for (int k = j; k < pos[i]; ++k)
                    used[k] = true;
                break;
            }
        }
    }
    pp[0] = 1;
    for (int i = 1; i < 2010; ++i) {
        pp[i] = pp[i - 1];
        pp[i] *= 2;
    }
    if (ans.empty()) {
        puts("0");
    } else {
        bigint res = 0;
        for (int i = 0; i < sz(ans); ++i)
            res += pp[ans[i]];
        res.print();
    }

    return 0;
}


#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_DEPRECATE

#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#pragma comment(linker, "/STACK:64000000")

template<class T> inline T sqr (T x) {return x * x;}

typedef long long int64;
typedef unsigned long long uint64;
typedef pair<int, int> pii;
typedef pair<int64, int64> pii64;
typedef pair<double, double> pdd;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
#define eps  1e-8
#define inf  0x7f7f7f7f
#define sfind(S, C) int((S).find(C))
#define sz(C) (int)((C).size())
#define all(C) (C).begin(), (C).end()
#define TASK "test"
#define RR 151

char used[1 << 11] = {0};
int pos[1 << 11];

struct bigint {
    static const int base = 1000*1000*1000;
    int n;
    int a[128];
    bigint () {
        n = 1;
        memset(a, 0, sizeof a);
    }
    bigint (int t) {
        n = 1;
        memset(a, 0, sizeof a);
        a[0] = t;
    }
    void operator *= (int b) {
        for (int i = 0, carry = 0; i < n || carry; ++i) {
            if (i == n) ++n;
            int64 cur = carry + a[i] * 1ll * b;
            carry = int(cur / base);
            a[i] = int(cur - carry * 1ll * base);
        }
    }
    void operator += (const bigint &b) {
        for (int i = 0, carry = 0; i < max(n, b.n) || carry; ++i) {
            if (i == n) ++n;
            a[i] += carry + (i < b.n ? b.a[i] : 0);
            carry = a[i] >= base;
            if (carry) a[i] -= base;
        }
    }
    void print() {
        printf("%d", a[n - 1]);
        for (int i = n - 2; i >= 0; --i)
            printf("%09d", a[i]);
    }
};

bigint pp[1 << 11];

int main() {
#ifndef ONLINE_JUDGE
    freopen(TASK ".in", "r", stdin);
    freopen(TASK ".out", "w", stdout);
#endif

    int T;
    scanf("%d\n", &T);
    char op[8];
    vector<int> ans;
    vector<pii> act;
    memset(pos, -1, sizeof pos);
    for (int x; T--; ) {
        scanf("%s%d", op, &x);
        if (op[0] == 's')
            pos[x] = sz(act);
        act.push_back(pii(op[0], x));
    }
    for (int i = 2000; i >= 0; --i) {
        if (pos[i] == -1) continue;
        for (int j = pos[i] - 1; j >= 0; --j) {
            if (used[j]) break;
            if (act[j].first == 'w' && act[j].second == i) {
                ans.push_back(i);
                for (int k = j; k >= 0 && act[k].first == 'w'; --k)
                    used[k] = true;
                for (int k = j; k < pos[i]; ++k)
                    used[k] = true;
                break;
            }
        }
    }
    pp[0] = 1;
    for (int i = 1; i < 2010; ++i) {
        pp[i] = pp[i - 1];
        pp[i] *= 2;
    }
    if (ans.empty()) {
        puts("0");
    } else {
        bigint res = 0;
        for (int i = 0; i < sz(ans); ++i)
            res += pp[ans[i]];
        res.print();
    }

    return 0;
}


#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_DEPRECATE

#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#pragma comment(linker, "/STACK:64000000")

template<class T> inline T sqr (T x) {return x * x;}

typedef long long int64;
typedef unsigned long long uint64;
typedef pair<int, int> pii;
typedef pair<int64, int64> pii64;
typedef pair<double, double> pdd;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
#define eps  1e-8
#define inf  0x7f7f7f7f
#define sfind(S, C) int((S).find(C))
#define sz(C) (int)((C).size())
#define all(C) (C).begin(), (C).end()
#define TASK "test"
#define RR 151

char used[1 << 11] = {0};
int pos[1 << 11];

struct bigint {
    static const int base = 1000*1000*1000;
    int n;
    int a[128];
    bigint () {
        n = 1;
        memset(a, 0, sizeof a);
    }
    bigint (int t) {
        n = 1;
        memset(a, 0, sizeof a);
        a[0] = t;
    }
    void operator *= (int b) {
        for (int i = 0, carry = 0; i < n || carry; ++i) {
            if (i == n) ++n;
            int64 cur = carry + a[i] * 1ll * b;
            carry = int(cur / base);
            a[i] = int(cur - carry * 1ll * base);
        }
    }
    void operator += (const bigint &b) {
        for (int i = 0, carry = 0; i < max(n, b.n) || carry; ++i) {
            if (i == n) ++n;
            a[i] += carry + (i < b.n ? b.a[i] : 0);
            carry = a[i] >= base;
            if (carry) a[i] -= base;
        }
    }
    void print() {
        printf("%d", a[n - 1]);
        for (int i = n - 2; i >= 0; --i)
            printf("%09d", a[i]);
    }
};

bigint pp[1 << 11];

int main() {
#ifndef ONLINE_JUDGE
    freopen(TASK ".in", "r", stdin);
    freopen(TASK ".out", "w", stdout);
#endif

    int T;
    scanf("%d\n", &T);
    char op[8];
    vector<int> ans;
    vector<pii> act;
    memset(pos, -1, sizeof pos);
    for (int x; T--; ) {
        scanf("%s%d", op, &x);
        if (op[0] == 's')
            pos[x] = sz(act);
        act.push_back(pii(op[0], x));
    }
    for (int i = 2000; i >= 0; --i) {
        if (pos[i] == -1) continue;
        for (int j = pos[i] - 1; j >= 0; --j) {
            if (used[j]) break;
            if (act[j].first == 'w' && act[j].second == i) {
                ans.push_back(i);
                for (int k = j; k >= 0 && act[k].first == 'w'; --k)
                    used[k] = true;
                for (int k = j; k < pos[i] && act[k].first == 'w'; ++k)
                    used[k] = true;
                break;
            }
        }
    }
    pp[0] = 1;
    for (int i = 1; i < 2010; ++i) {
        pp[i] = pp[i - 1];
        pp[i] *= 2;
    }
    if (ans.empty()) {
        puts("0");
    } else {
        bigint res = 0;
        for (int i = 0; i < sz(ans); ++i)
            res += pp[ans[i]];
        res.print();
    }

    return 0;
}


#include <stdio.h>
#include <math.h>
#include <string.h>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#pragma comment(linker, "/STACK:16777216")
using namespace std;

#define bit(n) (1<<(n))
#define inf 1000000000
#define eps 1e-9
#define pi 3.1415926535897932385
#define pb push_back
#define sz size()
#define mp make_pair
#define cl clear()
#define all(a) a.begin(),a.end()
#define fill(ar,val) memset(ar,val,sizeof ar)
#define MIN(a,b) if(a>(b)) a=(b)
#define MAX(a,b) if(a<(b)) a=(b)
#define sqr(x) ((x)*(x))
#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))

typedef vector<int> VI;
typedef pair<int,int> PII;
//typedef long long LL;

#define p_len 4
const int p=10000;
#define NN 666/p_len

struct num
{
    int len;
    int it[NN];
    num(int n=0)
    {
        for(len=0;n>0;n/=p) it[len++]=n%p;
    }
};

void operator+=(num &a,const num &b)
{
    int i,div=0;
    for(i=0;i<a.len || i<b.len;i++)
    {
        if(i<a.len) div+=a.it[i];
        if(i<b.len) div+=b.it[i];
        a.it[i]=div%p;
        div/=p;
    }
    if(div>0) a.it[i++]=div;
    a.len=i;
}

num operator*(int b,const num &a)
{
    num prod(0);
    if(b==0) return prod;
    int i,div=0;
    for(i=0;i<a.len;i++)
    {
        div+=a.it[i]*b;
        prod.it[i]=div%p;
        div/=p;
    }
    for(;div>0;div/=p) prod.it[i++]=div%p;
    prod.len=i;
    return prod;
}

void operator*=(num &a,int b)
{
    if(b==0) a.len=0; else
    {
        int i,div=0;
        for(i=0;i<a.len;i++)
        {
            div+=a.it[i]*b;
            a.it[i]=div%p;
            div/=p;
        }
        for(;div>0;div/=p) a.it[i++]=div%p;
        a.len=i;
    }
}

void print(num &a)
{
    if(a.len==0) printf("0"); else
    {
        long i=a.len-1;
        printf("%d",a.it[i]);
        char s[10];
        sprintf(s,"%%0%dd",p_len);
        for(i--;i>=0;i--) printf(s,a.it[i]);
    }
    printf("\n");
}

#define N 5050
#define X 2000
int a[N];
int b[X+1];
int mark[N];

int main()
{
    int n;
    while(scanf("%d",&n)>0)
    {
        int i,x;
        for(i=0;i<n;i++)
        {
            char tmp[11];
            scanf("%s %d",tmp,&x);
            if(tmp[0]=='w') a[i]=-x-1; else a[i]=x+1;
        }
        fill(b,0);
        fill(mark,0);
        for(x=X;x>=0;x--)
        {
            int curw=-1;
            for(i=0;i<n;i++)
                if(mark[i]) curw=-1; else
                if(a[i]==-x-1) curw=i; else
                if(a[i]==x+1 && curw>=0)
                {
                    b[x]++;
                    for(int j=curw;j<=i;j++) mark[j]=1;
                    curw=-1;
                }
        }
        num p2(1);
        num ans(0);
        for(x=0;x<=X;x++)
        {
            ans+=b[x]*p2;
            p2*=2;
        }
        print(ans);
    }
    return 0;
}


#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <limits>
#include <map>
using namespace std;

const int MAXD=1010;  // ����
const int DIG=9, BASE=1000000000;
const unsigned long long BOUND = numeric_limits<unsigned long long>::max()-(unsigned long long)BASE*BASE;

struct BigNum
{
    int D, digits[MAXD/DIG+2];

    inline void trim ()
    {
        while (D > 1 && digits [D - 1] == 0)
            D--;
    }

    inline void init (long long x)
    {
        memset (digits, 0, sizeof (digits));
        D = 0;

        do
        {
            digits [D++] = x % BASE;
            x /= BASE;
        }
        while (x > 0);
    }

    inline BigNum (long long x)
    {
        init (x);
    }

    inline BigNum (int x = 0)
    {
        init (x);
    }

    inline BigNum (char *s)
    {
        memset (digits, 0, sizeof (digits));
        int len = strlen (s), first = (len + DIG - 1) % DIG + 1;
        D = (len + DIG - 1) / DIG;

        for (int i = 0; i < first; i++)
            digits [D - 1] = digits [D - 1] * 10 + s [i] - '0';

        for (int i = first, d = D - 2; i < len; i += DIG, d--)
            for (int j = i; j < i + DIG; j++)
                digits [d] = digits [d] * 10 + s [j] - '0';

        trim ();
    }

    inline char *str ()
    {
        trim ();
        char *buf = new char [DIG * D + 1];
        int pos = 0, d = digits [D - 1];

        do
        {
            buf [pos++] = d % 10 + '0';
            d /= 10;
        }
        while (d > 0);

        reverse (buf, buf + pos);

        for (int i = D - 2; i >= 0; i--, pos += DIG)
            for (int j = DIG - 1, t = digits [i]; j >= 0; j--)
            {
                buf [pos + j] = t % 10 + '0';
                t /= 10;
            }

        buf [pos] = '\0';
        return buf;
    }

    inline bool operator < (const BigNum &o) const  // ����С��
    {
        if (D != o.D)
            return D < o.D;

        for (int i = D - 1; i >= 0; i--)
            if (digits [i] != o.digits [i])
                return digits [i] < o.digits [i];

        return false;
    }

    inline bool operator == (const BigNum &o) const   // �����
    {
        if (D != o.D)
            return false;

        for (int i = 0; i < D; i++)
            if (digits [i] != o.digits [i])
                return false;

        return true;
    }

    inline BigNum operator << (int p) const  // ��������
    {
        BigNum temp;
        temp.D = D + p;

        for (int i = 0; i < D; i++)
            temp.digits [i + p] = digits [i];

        for (int i = 0; i < p; i++)
            temp.digits [i] = 0;

        return temp;
    }

    inline BigNum operator >> (int p) const  // ��������
    {
        BigNum temp;
        temp.D = D - p;

        for (int i = 0; i < D - p; i++)
            temp.digits [i] = digits [i + p];

        for (int i = D - p; i < D; i++)
            temp.digits [i] = 0;

        return temp;
    }

    inline BigNum range (int a, int b) const
    {
        BigNum temp = 0;
        temp.D = b - a;

        for (int i = 0; i < temp.D; i++)
            temp.digits [i] = digits [i + a];

        return temp;
    }

    inline BigNum operator + (const BigNum &o) const  // �����
    {
        BigNum sum = o;
        int carry = 0;

        for (sum.D = 0; sum.D < D || carry > 0; sum.D++)
        {
            sum.digits [sum.D] += (sum.D < D ? digits [sum.D] : 0) + carry;

            if (sum.digits [sum.D] >= BASE)
            {
                sum.digits [sum.D] -= BASE;
                carry = 1;
            }
            else
                carry = 0;
        }

        sum.D = max (sum.D, o.D);
        sum.trim ();
        return sum;
    }

    inline BigNum operator - (const BigNum &o) const  // �����
    {
        BigNum diff = *this;

        for (int i = 0, carry = 0; i < o.D || carry > 0; i++)
        {
            diff.digits [i] -= (i < o.D ? o.digits [i] : 0) + carry;

            if (diff.digits [i] < 0)
            {
                diff.digits [i] += BASE;
                carry = 1;
            }
            else
                carry = 0;
        }

        diff.trim ();
        return diff;
    }

    inline BigNum operator * (const BigNum &o) const  // �����
    {
        BigNum prod = 0;
        unsigned long long sum = 0, carry = 0;

        for (prod.D = 0; prod.D < D + o.D - 1 || carry > 0; prod.D++)
        {
            sum = carry % BASE;
            carry /= BASE;

            for (int j = max (prod.D - o.D + 1, 0); j <= min (D - 1, prod.D); j++)
            {
                sum += (unsigned long long) digits [j] * o.digits [prod.D - j];

                if (sum >= BOUND)
                {
                    carry += sum / BASE;
                    sum %= BASE;
                }
            }

            carry += sum / BASE;
            prod.digits [prod.D] = sum % BASE;
        }

        prod.trim ();
        return prod;
    }

    inline double double_div (const BigNum &o) const
    {
        double val = 0, oval = 0;
        int num = 0, onum = 0;

        for (int i = D - 1; i >= max (D - 3, 0); i--, num++)
            val = val * BASE + digits [i];

        for (int i = o.D - 1; i >= max (o.D - 3, 0); i--, onum++)
            oval = oval * BASE + o.digits [i];

        return val / oval * (D - num > o.D - onum ? BASE : 1);
    }

    inline pair <BigNum, BigNum> divmod (const BigNum &o) const  // ���ģ
    {
        BigNum quot = 0, rem = *this, temp;

        for (int i = D - o.D; i >= 0; i--)
        {
            temp = rem.range (i, rem.D);
            int div = (int) temp.double_div (o);
            BigNum mult = o * div;

            while (div > 0 && temp < mult)
            {
                mult = mult - o;
                div--;
            }

            while (div + 1 < BASE && !(temp < mult + o))
            {
                mult = mult + o;
                div++;
            }

            rem = rem - (o * div << i);

            if (div > 0)
            {
                quot.digits [i] = div;
                quot.D = max (quot.D, i + 1);
            }
        }

        quot.trim ();
        rem.trim ();
        return make_pair (quot, rem);
    }

    inline BigNum operator / (const BigNum &o) const  // �����
    {
        return divmod (o).first;
    }

    inline BigNum operator % (const BigNum &o) const  // ����ģ
    {
        return divmod (o).second;
    }

    inline BigNum power (int exp) const  // ������
    {
        BigNum p = 1, temp = *this;

        while (exp > 0)
        {
            if (exp & 1) p = p * temp;
            if (exp > 1) temp = temp * temp;
            exp >>= 1;
        }

        return p;
    }
};

typedef pair<string, int> Item;

Item it[5010];
bool used[5010];
int exist[2010];

BigNum calc(int x);

int main()
{
	string str;
	int n;
	map< int, int, greater<int> > mp;
	map< int, int, greater<int> >::iterator ptr;

	cin>>n;
	memset(exist, 0x7f, sizeof(exist));
	for(int i=0; i<n; i++)
	{
		cin>>it[i].first>>it[i].second;
		if( it[i].first[0] == 's' )
			mp.insert(make_pair(it[i].second, i));
		if( it[i].first[0] == 'w' )
			exist[it[i].second] = min(i, exist[it[i].second]);
	}

	BigNum ans(0);
	for(ptr=mp.begin(); ptr!=mp.end(); ptr++)
	{
		if( exist[ptr->first] > ptr->second )
			continue;
		for(int i=ptr->second; i>=0; i--)
		{
			if( used[i] )
				break;
			used[i] = 1;
			if( it[i].first[0]=='w' && it[i].second==ptr->first )
			{
				ans = ans+calc(ptr->first);
				break;
			}
		}
	}
	printf("%s\n", ans.str());

	return 0;
}

BigNum calc(int x)
{
	BigNum t;

	if( x < 63 )
		return BigNum(1<<x);
	t = calc(x/2);
	if( x%2 == 0 )
		return t*t;
	else
		return t*t*BigNum(2);
}