Problem:
Score : 500 points

Problem Statement

For an integer n not less than 0, let us define f(n) as follows:

f(n) = 1 (if n < 2)

f(n) = n f(n-2) (if n \geq 2)

Given is an integer N. Find the number of trailing zeros in the decimal notation of f(N).

Constraints

0 \leq N \leq 10^{18}

Input

Input is given from Standard Input in the following format:

N

Output

Print the number of trailing zeros in the decimal notation of f(N).

Sample Input 1

12

Sample Output 1

1

f(12) = 12 × 10 × 8 × 6 × 4 × 2 = 46080, which has one trailing zero.

Sample Input 2

5

Sample Output 2

0

f(5) = 5 × 3 × 1 = 15, which has no trailing zeros.

Sample Input 3

1000000000000000000

Sample Output 3

124999999999999995

Solution in C++14 (GCC 5.4.1) (judge verdict: Accepted)

#define STOPIT
#include <bits/stdc++.h>
#define loop(n) for (lint ngtkana_is_a_genius = 0; ngtkana_is_a_genius < lint(n); ngtkana_is_a_genius++)
#define rep(i, begin, end) for (lint i = lint(begin); (i) < lint(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto& a, auto b){ if (a > b) {a = b; return true;} return false; };
auto cmx = [](auto& a, auto b){ if (a < b) {a = b; return true;} return false; };
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
#define debug(...)\
  do {\
    std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_impl(__VA_ARGS__);\
    std::cerr << std::noboolalpha;\
  } while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
 os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  lint max = std::numeric_limits<lint>::max() / 25;
  auto make_p = [&] (lint base) {
    std::vector<lint> p={1};
    while (true) {
      lint x = p.back() * base;
      if (max < x) break;
      p.emplace_back(x);
    }
    return p;
  };
  auto p2 = make_p(2);
  auto p5 = make_p(5);
  // debug(p2,p5);

  auto g = [&] (auto&& g, lint X) -> lint {
    if (X < 2) return 0;
    auto ub = std::upper_bound(all(p2),X);
    assert(ub != p2.begin());
    lint P = *std::prev(ub);
    lint x = P - 1;
    lint y = g(g, X - P);
    lint ans = x + y;
    return ans;
  };
  auto h = [&] (auto&& h, lint X) -> lint {
    if (X < 5) return 0;
    auto ub = std::upper_bound(all(p5),X);
    assert(ub != p5.begin());
    lint P = *std::prev(ub);
    lint x = P - 1;
    assert(x % 4 == 0);
    x /= 4;
    lint y = h(h, X - P);
    lint ans = x + y;
    return ans;
  };

  // rep(i,0,20) {
  //   debug(i,g(g,i));
  // }
  // rep(i,0,30) {
  //   debug(i,h(h,i));
  // }
  lint X; std::cin >> X;
  lint ans = -1;
  if (X % 2 == 1) {
    ans = 0;
  } else {
    lint x = g(g, X);
    lint y = h(h, X / 2);
    debug(x,y);
    ans = std::min(x,y);
  }
  std::cout << ans << std::endl;
  return 0;
}