FTCRL - Having problems with trailing zeros of a factorial

Regarding the practice problem -

I have written the following code-

#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<assert.h>
using namespace std;
#define size 1000000
int main()
{
char b[size];
int c,cnt=0;
long int num,count;
fgets(b,size,stdin);
sscanf(b,"%ld",&count);
assert(count<=100000);
int i=0;
while((c=fread(b,1,size,stdin))>0)
{		
	for(int j=0;j<c;j++)
	{			
		if(b[j]=='\n')
		{				
			i++;				
			while(num)
			{
				num=num/5;					
				cnt=cnt+num;
				
			}
			cout<<"\n"<<cnt;
			cnt=0;
			if(i==count)
				break;
		}
		else
		{				
			num=num*10+(b[j]-'0');
		}
	}
	if(i==count)
		break;
}
cout<<endl;	
return 0;
}

I think my logic is correct, But it gives wrong answer.Please help I am new to programming.

//