#include<iostream>
using namespace std;
string a;
struct asdf{
char a;
int dly , dlh;
};
queue<char> q;
stack<asdf> s;
int dly = 0, dlh = 0;
int main(){
cin >> a;
int len = a.size();
for(int i = 0; i < len; i++){
if(a[i] == '1' || a[i] == '0'){
q.push(a[i]);
}else if(a[i] == ')'){
while(!s.empty() && s.top().a != '('){
q.push(s.top().a);
s.pop();
}
if(!s.empty() && s.top().a == '('){
s.pop();
}
}else if(a[i] == '('){
s.push({a[i] , 0 , 0});
}else if(a[i] == '&'){
while(!s.empty() && s.top().a == '&' && s.top().a != '('){
q.push(s.top().a);
s.pop();
}
s.push({a[i] , 0 , 0});
}else if(a[i] == '|'){
while(!s.empty() && (s.top().a == '&' || s.top().a == '|') && s.top().a != '('){
q.push(s.top().a);
s.pop();
}
s.push({a[i] , 0 , 0});
}
}
while(!s.empty()){
q.push(s.top().a);
s.pop();
}
while(!q.empty()){
if(q.front() == '1' || q.front() == '0'){
s.push({q.front() , 0 , 0});
}else if(q.front() == '|'){
char x = s.top().a;
int dly_1 = s.top().dly , dlh_1 = s.top().dlh;
s.pop();
char y = s.top().a;
int dly_2 = s.top().dly , dlh_2 = s.top().dlh;
s.pop();
if(y == '1'){
dlh_2++;
s.push({'1' , dly_2 , dlh_2});
}else{
if(x == '1'){
s.push({'1' , dly_2 + dly_1 , dlh_2 + dlh_1});
}else{
s.push({'0' , dly_2 + dly_1 , dlh_2 + dlh_1});
}
}
}else{
char x = s.top().a;
int dly_1 = s.top().dly , dlh_1 = s.top().dlh;
s.pop();
char y = s.top().a;
int dly_2 = s.top().dly , dlh_2 = s.top().dlh;
s.pop();
if(y == '0'){
dly_2++;
s.push({'0' , dly_2 , dlh_2});
}else{
if(x == '1'){
s.push({'1' , dly_2 + dly_1 , dlh_2 + dlh_1});
}else{
s.push({'0' , dly_2 + dly_1 , dlh_2 + dlh_1});
}
}
}
q.pop();
}
cout << s.top().a << "\n";
cout << s.top().dly << " " << s.top().dlh;
return 0;
}