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