n = int(input()) x = 1 ans = 0 while x*x <= n: o = n // x cnt = 1 for i in range(60): x_bit = (x >> i) & 1 o_vit = (o >> i) & 1 if x_bit == 1 and o_vit == 1: cnt *= 2 cnt %= 10**9+7 if x_bit == 1 and o_vit == 0: cnt = 0 ans += cnt x += 1 print(ans // 2)