50pts
求助
//
// main.cpp
// IDE
//
// Created by aa on 2022/12/30.
//
////
//
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <cstdio>
using namespace std;
#define ll long long
const ll N=1000;
int fx[20]={-1,0,1,0,-1,1,1,-1};
int fy[20]={0,1,0,-1,1,-1,1,-1};
char a[N][N];
int d[N][N];
bool vis[N][N];
void inp_io(){
std::ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
int dfs(){
string temp;
int ans=0,k;
char c,x;
while(cin>>c){
if(c==']') break;
cin>>temp>>k;
if(c=='R'){
x=getchar();
ans+=k*dfs();
x=getchar();
}if(c=='B'){
x=getchar();
ans-=k;
}if(c=='F'){
x=getchar();
ans+=k;
}if(x==']') break;
}
return ans;
}
int main(){
inp_io();
cout<<abs(dfs())<<endl;
return 0;
}