#include<bits/stdc++.h>
#define int long long
using namespace std;
string s,ss;
int ansa,anso;
stack<char> s2,f;
struct t{
int l,r;
char c;
}tree[2000100];
void gettree(int i){
tree[i].c=s2.top();
s2.pop();
if(tree[i].c=='0'||tree[i].c=='1')return;
tree[i].l=2*i;
tree[i].r=2*i+1;
gettree(2*i+1);
gettree(2*i);
return;
}
void ys(int i){
if(tree[i].c=='|'||tree[i].c=='&'){
ys(2*i);
}
if(i%2==1)return;
char c=tree[i].c;
if(c=='1'&&tree[i/2].c=='|'){
anso++;
tree[i/2].c='1';
return;
}
if(c=='0'&&tree[i/2].c=='&'){
ansa++;
tree[i/2].c='0';
return;
}
ys(i+1);
tree[i/2].c=tree[i+1].c;
return;
}
signed main(){
cin >> s;
for(int i=0;i<s.size();i++){
char c=s[i];
if(c<='9'&&c>='0'){
s2.push(c);
}else if(c=='('){
f.push(c);
}else if(c==')'){
while(f.top()!='('){
s2.push(f.top());
f.pop();
}
f.pop();
}else{
again:
if(f.empty()||f.top()=='('){
f.push(c);
}else if(c=='&'&&f.top()=='|'){
f.push(c);
}else{
s2.push(f.top());
f.pop();
goto again;
}
}
}
while(!f.empty()){
s2.push(f.top());
f.pop();
}
gettree(1);
ys(1);
cout << tree[1].c << "\n" << ansa << " " << anso;
return 0;
}