#include <stdio.h>
#include <stdlib.h>
int n = 0;
typedef struct TNode
{
char data;
struct TNode* lchild;
struct TNode* rchild;
}TNode;
TNode* creat()
{
char x;
TNode* pT;
scanf("%c", &x);
if (x == '#')
pT = NULL;
else
{
pT = (TNode*)malloc(sizeof(TNode));
pT->data = x;
pT->lchild = creat();
pT->rchild = creat();
}
return pT;
}
void count(TNode* pT)
{
if (pT == NULL)
return;
else
{
if (pT->lchild != NULL && pT->rchild != NULL)
n++;
count(pT->lchild);
count(pT->rchild);
}
}
int main()
{
TNode* pT;
pT = creat();
count(pT);
printf("%d", n);
return 0;
}