fermat_primes = [3, 5, 17, 257, 65537] def compute_max_m(s, A): if s == 0: return -1 target = A // s if target == 0: return -1 m = 0 current = 1 while current * 2 <= target: current *= 2 m += 1 return m A = int(input()) count = 0 for mask in range(0, 1 << 5): # There are 5 Fermat primes product = 1 for j in range(5): if mask & (1 << j): product *= fermat_primes[j] if product > A: break # Early exit if product exceeds A if product > A: continue # Skip products exceeding A if product == 1: # Handle case where product is 1 (empty subset) # We need m >= 2 (since n = 2^m must be >=3) max_exp = compute_max_m(1, A) if max_exp >= 2: count += (max_exp - 2 + 1) else: # For other products, compute valid m max_exp = compute_max_m(product, A) if max_exp >= 0: count += (max_exp + 1) print(count)