import java.util.*; class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); long n = in.nextLong(); int c = 0; for(long i = 0; i <= n; i++) { for(long j = i; j <= n; j++) { if((i&j) < (i^j) && (i^j) < (i|j)) c++; } } System.out.println(c%1000000007); } }