#include <fstream>
using namespace std;
#define max1 9223372036854775807
#define lung unsigned long long int
#define lung1 long long int
lung fact(lung n) {
lung p = 0;
for(int i = 1; 5*i <= n; i = i*5) {
p += n / 5*i;
}
return p;
}
lung1 binary(lung x, lung st, lung dr) {
lung mid = fact((st + dr) / 2);
if(st == dr) {
if(x == mid)
return mid;
else
return -1;
}
else {
if(x > mid)
return binary(x, st, mid-1);
else
return binary(x, mid+1, dr);
}
}
int main(void) {
ifstream in("fact.in");
ofstream out("fact.out");
lung p;
in >> p;
if(p >= 0) {
lung n = binary(p, 0, max1);
out << n;
}
else {
out << -1;
}
}