#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int dp[25][100005];
int ans;
long long n;
void solve() {
  scanf("%lld", &n);
  assert(n <= 100000);
  dp[0][0] = 1;
  for (int i = 0; i < 20; ++i) {
    for (int v = 0; v <= n; ++v) {
      for (int j = 0; j <= 2; ++j) {
        int to = v + j * (1 << i);
        if (to <= n) {
          dp[i + 1][to] += dp[i][v];
          dp[i + 1][to] %= mod;
        }
      }
    }
  }
  for (int i = 0; i <= n; ++i) {
    ans += dp[20][i];
    ans %= mod;
  }
  printf("%d", ans);
}
int main() {
  int tt = 1;
  while (tt--) {
    solve();
  }
  return 0;
}
