#include<bits/stdc++.h>
template<typename _Tp>void read(_Tp &x){
	char ch=getchar();bool f=0;while(!isdigit(ch))f|=ch=='-',ch=getchar();
	x=ch&15,ch=getchar();while(isdigit(ch))x=x*10+(ch&15),ch=getchar();
	if(f)x=-x;
}
template<typename _Tp,typename ...Args>void read(_Tp &x,Args &...args){read(x),read(args...);}

int main(){
	int cnt=0;
	while(true){
		system("./gen > in;./noodle < in > out;./baoli < in > ans");
		if(system("diff -b ./out ./ans"))break;
		printf("%d\n",++cnt);
	}
	return 0;
}
