#include <bits/stdc++.h>
#define int long long
using namespace std;
string s;
stack<int> ns;
stack<char> fs;
stack<pair<int,int>> ds;
map<char,int> pri;
void calc() {
int b=ns.top();
ns.pop();
int a=ns.top();
ns.pop();
auto db=ds.top();
ds.pop();
auto da=ds.top();
ds.pop();
int tmp=0;
if(fs.top()=='&') tmp=a&b;
else if(fs.top()=='|') tmp=a|b;
ns.push(tmp);
if(a==0&&fs.top()=='&') ds.push({da.first+1,da.second});
else if(a==1&&fs.top()=='|') ds.push({da.first,db.second+1});
else ds.push({da.first+db.first,da.second+db.second});
fs.pop();
return ;
}
signed main() {
ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
cin>>s;
pri['|']=0;
pri['&']=1;
for(int i=0; i<s.size(); i++) {
if(isdigit(s[i])) {
ns.push(s[i]-'0');
ds.push({0,0});
} else {
if(s[i]=='(') {
cout<<"i="<<i;
fs.push('(');
}
if(s[i]==')') {
while(!fs.empty()&&fs.top()!='(') calc();
if(!fs.empty()) fs.pop();
}
if(s[i]!='('&&s[i]!=')') {
while(!fs.empty()&&pri[fs.top()]>=pri[s[i]]) calc();
fs.push(s[i]);
}
}
}
while(!fs.empty()) calc();
cout<<ns.top()<<'\n'<<ds.top().first<<' '<<ds.top().second<<'\n';
return 0;
}