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

#SP0000201. Giả thuyết Paul Erdős (A Conjecture of Paul Erdős)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Giả thuyết Paul Erdős (A Conjecture of Paul Erdős)

A Conjecture of Paul Erdős

Phuoc Hung OJ problem: PRIME000206
Reference: SPOJ HS08PAUL
Adaptation: one original query per PHOJ execution; subtasks are PHOJ-specific groups.

Problem statement

Count positive primes p≤np\le n representable as p=x2+y4p=x^2+y^4 for integers x,yx,y. Each prime is counted once, even if multiple representations exist.

Input

One positive integer nn (one query extracted from the original multiple-query input).

Output

Print the number of distinct qualifying primes.

Subtasks

  • Subtask 1 (20 points): 1≤n≤10001\le n\le1000.
  • Subtask 2 (30 points): 1000<n≤1051000<n\le10^5.
  • Subtask 3 (50 points): 105<n<10710^5<n<10^7.

Example

Input

10

Output

2

Explanation: 2=12+142=1^2+1^4 and 5=22+145=2^2+1^4 are the qualifying primes at most 1010. No other prime in the range has the required representation.