#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
bool can[100005];
int ans;
int n;
void solve() {
  scanf("%d", &n);
  assert(n <= 5000);
  ans = n + 1;
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j <= i; ++j) {
      can[j] = 0;
    }
    for (int j = 0; j <= i; ++j) {
      if (j <= i - j) {
        can[j ^ (i - j)] = 1;
      }
    }
    for (int j = 0; j < i; ++j) {
      ans += can[j];
      ans %= mod;
    }
  }
  printf("%d", ans);
}
int main() {
  int tt = 1;
  while (tt--) {
    solve();
  }
  return 0;
}
