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

#GL0000263. Đếm số nguyên không chứa bình phương (Counting Square-free Integers)

HỌC THEO LỘ TRÌNH

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

2 lộ trình

Đếm số nguyên không chứa bình phương (Counting Square-free Integers)

Counting Square-free Integers

Source: Library Checker

Version: Phuoc Hung OJ Extended

Problem Statement

A positive integer xx is square-free if there is no integer d≥2d\ge 2 such that d2d^2 divides xx. Equivalently, each prime occurs at most once in the prime factorization of xx.

Given a positive integer NN, count all square-free integers xx such that 1≤x≤N1\le x\le N. The integer 11 is included.

Input

One line contains the positive integer NN.

Output

Print a single integer: the number of square-free integers from 11 through NN, inclusive.

Subtasks

  • Subtask 1 (20 points): 1≤N≤1061\le N\le 10^6. Time limit: 22 s.
  • Subtask 2 (30 points): 1≤N≤10121\le N\le 10^{12}. Time limit: 55 s.
  • Subtask 3 (50 points): 1≤N≤10181\le N\le 10^{18}. Time limit: 1010 s.

Examples

Input

10

Output

7

Explanation

The square-free integers between 11 and 1010 are 1,2,3,5,6,7,101,2,3,5,6,7,10, so the answer is 77. The values 44 and 88 are divisible by 222^2, while 99 is divisible by 323^2.