from fractions import gcd from datetime import date from math import factorial import functools from heapq import* from collections import deque import collections import math from collections import defaultdict, Counter import sys sys.setrecursionlimit(10 ** 7) MOD = 10 ** 9 + 7 inf = float("inf") 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 return [i for i in range(n + 1) if is_prime[i]] def is_prime(n): if n == 1: return False for k in range(2, int(math.sqrt(n)) + 1): if n % k == 0: return False return True def main(): n = int(input()) l = primes(n) d = Counter(l) ans = 0 for i in l: for j in l: if j ** 2 - i <= 0 or j ** 2 - i > n: continue if d[j ** 2 - i] == 1: ans += 1 print(ans) if __name__ == '__main__': main()