#![allow(unused_imports)] use std::cmp::*; use std::collections::*; use std::io::Write; use std::ops::Bound::*; #[allow(unused_macros)] macro_rules! debug { ($($e:expr),*) => { #[cfg(debug_assertions)] $({ let (e, mut err) = (stringify!($e), std::io::stderr()); writeln!(err, "{} = {:?}", e, $e).unwrap() })* }; } fn main() { let n = read::(); let mut squares = vec![]; for i in 1.. { if i * i > n { break; } squares.push(i as i64 * i as i64); } squares.reverse(); let mut numbers = vec![0i64; n + 1]; for i in 1..=n { numbers[i] = i as i64; } for &sq in &squares { let mut cur = sq; while cur <= n as i64 { if numbers[cur as usize] % sq == 0 { numbers[cur as usize] /= sq; } cur += sq } } if n < 50 { debug!(numbers); } squares.reverse(); let criterion = |x, mid| { if mid == squares.len() { return false; } x * squares[mid] <= n as i64 }; let mut ans = 0; for i in 1..=n { let (ok, _) = binary_search(0, squares.len(), |mid: usize| criterion(numbers[i], mid)); ans += ok as i64 + 1; } println!("{}", ans); } type Input = usize; fn binary_search(lb: Input, ub: Input, criterion: F) -> (Input, Input) where F: Fn(Input) -> bool, { assert_eq!(criterion(lb), true); assert_eq!(criterion(ub), false); let mut ok = lb; let mut ng = ub; while ng - ok > 1 { let mid = (ng + ok) / 2; if criterion(mid) { ok = mid; } else { ng = mid; } } (ok, ng) } fn read() -> T { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().parse().ok().unwrap() } fn read_vec() -> Vec { read::() .split_whitespace() .map(|e| e.parse().ok().unwrap()) .collect() }