#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

ull mul_mod(ull a, ull b, ull mod) {
    return (__uint128_t)a * b % mod;
}

ull pow_mod(ull a, ull d, ull mod) {
    ull result = 1;
    a %= mod;
    while (d) {
        if (d & 1) result = mul_mod(result, a, mod);
        a = mul_mod(a, a, mod);
        d >>= 1;
    }
    return result;
}

bool is_prime_mr(ull n) {
    if (n < 2) return false;
    if (n == 2 || n == 3) return true;
    if (n % 2 == 0) return false;

    ull d = n - 1;
    int s = 0;
    while ((d & 1) == 0) {
        d >>= 1;
        s++;
    }

    vector<ull> bases = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37};
    for (ull a : bases) {
        if (a >= n) continue;
        ull x = pow_mod(a, d, n);
        if (x == 1 || x == n - 1) continue;
        bool composite = true;
        for (int r = 1; r < s; r++) {
            x = mul_mod(x, x, n);
            if (x == n - 1) {
                composite = false;
                break;
            }
        }
        if (composite) return false;
    }
    return true;
}

ull f(ull x, ull c, ull mod) {
    return (mul_mod(x, x, mod) + c) % mod;
}

ull pollard_rho(ull n) {
    if (n % 2 == 0) return 2;
    ull x = rand() % (n - 2) + 2;
    ull y = x;
    ull c = rand() % (n - 1) + 1;
    ull d = 1;
    while (d == 1) {
        x = f(x, c, n);
        y = f(f(y, c, n), c, n);
        d = __gcd((x > y ? x - y : y - x), n);
    }
    if (d == n) return pollard_rho(n);
    return d;
}

ull find_smallest_prime_factor(ull n) {
    if (is_prime_mr(n)) return n;
    ull factor = pollard_rho(n);
    while (!is_prime_mr(factor)) {
        factor = pollard_rho(factor);
    }
    return factor;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    srand(time(0));

    ull N;
    cin >> N;

    if (N < 4) {
        cout << 0 << endl;
        return 0;
    }

    ull p = find_smallest_prime_factor(N);
    ull q = N / p;

    if (is_prime_mr(p) && is_prime_mr(q)) {
        if (p == q) {
            cout << 1 << endl;
        } else {
            cout << 2 << endl;
        }
    } else {
        cout << 0 << endl;
    }

    return 0;
}
