import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

void main() {
    auto N = readln.chomp.to!long;

    if (N % 2 == 0) {
        writeln(N / 2);
        return;
    }

    long f = 2;
    for (; f * f <= N; ++f) {
        if (N % f == 0) {
            writeln(1 + (N - f) / 2);
            return;
        }
    }

    writeln(1);
}
