import sys sys.setrecursionlimit(10**7) def I(): return int(sys.stdin.readline().rstrip()) def MI(): return map(int,sys.stdin.readline().rstrip().split()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LI2(): return list(map(int,sys.stdin.readline().rstrip())) def S(): return sys.stdin.readline().rstrip() def LS(): return list(sys.stdin.readline().rstrip().split()) def LS2(): return list(sys.stdin.readline().rstrip()) def sieve_of_eratosthenes(n): # n以下の素数の全列挙 prime_list = [] is_prime = [1]*(n+1) # A[i] = iが素数なら1,その他は0 is_prime[0] = is_prime[1] = 0 for i in range(2,int(n**.5)+1): if is_prime[i]: prime_list.append(i) for j in range(i**2,n+1,i): is_prime[j] = 0 for i in range(int(n**.5)+1,n+1): if is_prime[i] == 1: prime_list.append(i) return is_prime N = I() is_prime = sieve_of_eratosthenes(N) if N == 1: print(0) exit() ans = 1 a = 0 for r in range(3,N+1): if is_prime[r]: p = r**2-2 if p > N: break if is_prime[p]: a += 1 ans += 2*a print(ans)