#include <bits/stdc++.h>
#define Dim 100006
#define Mrot -10000008
#define Mpat -10000005
using namespace std;
ifstream f("expresie2.in"); // 10- [] 11-()
ofstream g("expresie2.out");
char S[Dim];
int N[Dim],cnt,sum,ans1;
unordered_map < char,long > Map;
stack <int> V;
int main()
{
Map['1']=1;Map['2']=2;Map['3']=3;Map['4']=4;Map['8']=8;Map['5']=5;Map['6']=6;Map['7']=7;Map['9']=9;Map['[']=Mpat+1;Map[']']=Mpat;
Map['(']=Mrot+1;Map[')']=Mrot;
f.get(S,Dim);
for(unsigned int i=0;i<strlen(S);i++)
if(S[i]!=',')
{
if(S[i-1]=='-'&&S[i]>='0'&&S[i]<='9')
{
if(S[i+1]<'0'||S[i+1]>'9')
V.push((-1)*Map[S[i]]);
else
if(S[i+1]>='0'&&S[i+1]<='9')
{
V.push((-1)*(10*Map[S[i]]+Map[S[i+1]]));
i++;
}
ans1++;
}
else
if(S[i]!='-'&&S[i]>='0'&&S[i]<='9')
{
if(S[i+1]<'0'||S[i+1]>'9')
V.push(Map[S[i]]);
else
if(S[i+1]>='0'&&S[i+1]<='9')
{
V.push(10*Map[S[i]]+Map[S[i+1]]);
i++;
}
if(V.top()>=1&&V.top()<=99)
ans1++;
}
else
if(S[i]!='-')
{
V.push(Map[S[i]]);
}
if(V.top()==Mpat)
{
V.pop();
while(V.top()!=Mpat+1)
{
N[++cnt]=V.top();
V.pop();
}
V.pop();
nth_element(N+1,N+((cnt+1)/2),N+cnt+1);
int val=N[(cnt+1)/2];
V.push(val);
cnt=0;
}
if(V.top()==Mrot)
{
V.pop();
long sum=0,maxim=Mrot;
while(V.top()!=Mrot+1)
{
sum+=V.top();
maxim=max(maxim,sum);
if(sum<0) sum=0;
V.pop();
}
V.pop();
V.push(maxim);
}
}
while(!V.empty())
{
sum+=V.top();
V.pop();
}
g<<ans1<<'\n'<<sum;
return 0;
}