示例输入
示例输出
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<map>
#include<queue>
#include<math.h>
#include<algorithm>
#include<cstdlib>
#define ll __int64
#define inf 0x3f3f3f3f
using namespace std;
struct node
{
char c;
node *l,*r;
};
char s[100];int ans=0,tmp;
node *bu(node *rt)
{
rt=new node;
char d=s[tmp++];
if(d==',')
rt=NULL;
else
{
rt->c=d;
rt->l=bu(rt->l);
rt->r=bu(rt->r);
}
return rt;
}
node *so(node *rt)
{
if(rt)
{
if(rt->l==NULL&&rt->r==NULL)
{
ans++;
}
else
{
so(rt->l);
so(rt->r);
}
}
}
int main()
{
int n,m,i,j,k;
while(~scanf("%s",s))
{
ans=0;
node *rt;
rt=new node;
tmp=0;
rt=bu(rt);
so(rt);
printf("%d\n",ans);
}
return 0;
}