from math import sqrt def primes(n): is_prime = [True] * (n + 1) is_prime[0] = False is_prime[1] = False for i in range(2, int(n**0.5) + 1): if not is_prime[i]: continue for j in range(i * 2, n + 1, i): is_prime[j] = False l = [False]*(n+1) for i in range(n+1): if is_prime[i]: l[i] = True return l N = int(input()) R = int(sqrt(10**6)) arr = primes(5*(10**5)+1) count = 0 for r in range(1,min(N,R)+1): if arr[r]: for p in range(1,N+1): q = r**2-p if q > N or q < 1: continue if arr[p] and arr[q]: count += 1 print(count)