long a,b,s,t;main(){for(scanf("%ld",&b);~b&1?b/=2,++t:b%5<1?b/=5,++s:0;);a?a=!printf("%d",a%b?-1:s