//이게 ㄹㅇ 고통
#include <stdio.h>
#include <stdlib.h>
typedef struct node{
int val;
struct node* lnext;
struct node* rnext;
}node;
void givelchild(node *, int);
void giverchild(node *, int);
int find(node * ,int);
int main()
{
int a;
node head;
head.val=1;
head.lnext=NULL;
head.rnext=NULL;
givelchild(&head,2);
giverchild(&head,3);
givelchild(head.lnext,4);
giverchild(head.rnext,5);
scanf("%d",&a);
printf("%d ",find(&head,a));
return 0;
}
void givelchild(node * target, int newval)
{
node * newnode=(node *)malloc(sizeof(node));
newnode->val=newval;
target->lnext=newnode;
newnode->lnext=NULL;
newnode->rnext=NULL;
}
void giverchild(node * target, int newval)
{
node * newnode=(node *)malloc(sizeof(node));
newnode->val=newval;
target->rnext=newnode;
newnode->lnext=NULL;
newnode->rnext=NULL;
}
int find(node * target,int findint)
{
int flag=0;
if(target->val==findint) return 1;
if(target->lnext==NULL && target->rnext==NULL) return 0;
if(target->lnext!=NULL) flag+=find(target->lnext,findint);
if(target->rnext!=NULL) flag+=find(target->rnext,findint);
if(flag==0) return 0;
else return 1;
}