#include <cstdio>
#include <cmath>
int main()
{
    long long n, sum = 0;
    scanf("%lld", &n);
    long long lmt = sqrt(n) + 5;
    for (long long i = 2; i <= lmt; i++)
        if (n % i == 0)
        {
            sum = (n - i) / 2;
            break;
        }
    printf("%lld", sum + 1);
    return 0;
}