We arrange the numbers between 1 and N (1 <= N <= 10000) in increasing order and decreasing order like this:

1 2 3 4 5 6 7 8 9 . . . N N . . . 9 8 7 6 5 4 3 2 1

Two numbers faced each other form a pair. Your task is to compute the number of pairs P such that both numbers in the pairs are prime.

Input contains several test cases. Each test case consists of an integer N in one line.

For each line of input, output P .

1 4 7 51

0 2 2 6

Source: Introduction to AOJ
, Aizu-Wakamatsu, Japan

Problem Setter: team86

Problem Setter: team86