#include<bits/stdc++.h>
using namespace std;
#define ll long long
int ans=0;
class node {
public:
node *left;
node *right;
int val;
node(int val) {
this->val=val;
left=NULL;
right=NULL;
}
};
ll func_left(node *root) {
if(!root || root->val==INT_MAX) return 0;
return root->val+func_left(root->left);
}
ll func_right(node *root) {
if(!root || root->val==INT_MAX) return 0;
return root->val+func_right(root->right);
}
void dfs(node *root) {
if(!root) return;
if(!root->left || root->left->val==INT_MAX || !root->right || root->right->val==INT_MAX) return;
ll a=func_left(root->left);
ll b=func_right(root->right);
if(a==-b) ans++;
dfs(root->left);
dfs(root->right);
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
queue<node*> que;
string s;
node *root=NULL;
while(cin >> s) {
if(root==NULL) {
root=new node(stoi(s));
que.push(root);
}
else {
if(que.front()->left) {
if(s=="null") {
que.front()->right=new node(INT_MAX);
que.pop();
continue;
}
node *temp=new node(stoi(s));
que.front()->right=temp;
que.pop();
que.push(temp);
}
else {
if(s=="null") {
que.front()->left=new node(INT_MAX);
continue;
}
node *temp=new node(stoi(s));
que.front()->left=temp;
que.push(temp);
}
}
}
dfs(root);
cout << ans << "\n";
return 0;
}