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

int[] di = [1,0,-1,0,1,1,-1,-1], dj = [0,1,0,-1,1,-1,1,-1];
int ans;

void main() {
    while (1) {
        int n;
        scan(n);

        if (!n) return;

        auto ans = cntp(n);
        writeln(ans);
    }
}

int cntp(int n) {
    int cnt;

    foreach (a ; n + 1 .. 2*n + 1) {
        cnt += isPrime(a);
    }

    return cnt;
}

bool isPrime(int a) {
    for (int p = 2; p*p <= a; p++) {
        if (a % p == 0) {
            return false;
        }
    }
    return true;
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}