PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#SP0000127. Đếm cặp Goldbach (Goldbach's Conjecture)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Đếm cặp Goldbach (Goldbach's Conjecture)

Goldbach's Conjecture

Source: LightOJ

Version: Phuoc Hung OJ Extended

Problem Statement

Given an even integer n≥4n\ge4, count all pairs (a,b)(a,b) such that aa and bb are prime, a+b=na+b=n, and a≤ba\le b. Each unordered pair is counted once.

Only the number of valid pairs is required; the pairs themselves do not need to be listed.

Input

One line containing the integer nn.

Output

Print a single integer: the count of valid pairs (without any Case prefix).

Subtasks

  • Subtask 1 (20 points): 4≤n≤1004\le n\le 100; nn is even.
  • Subtask 2 (30 points): 4≤n≤300004\le n\le 30000; nn is even.
  • Subtask 3 (50 points): 4≤n≤100000004\le n\le 10000000; nn is even.

Examples

Input

22

Output

3

Explanation

For n=22n=22, the qualifying pairs are (3,19)(3,19), (5,17)(5,17) and (11,11)(11,11). The pair (7,15)(7,15) is invalid because 1515 is composite. Hence the answer is 3.