#include <bits/stdc++.h>
using namespace std;
template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;
template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using GPQ = priority_queue<T, vector<T>, greater<T>>;
using ll = long long;
template <typename T>
T sq(T a) {
  return a * a;
}
template <typename T, typename U>
void testP2(T a, U b) {
  cout << "(" << a << ", " << b << ")" << endl;
  return;
}
template <typename T>
void testV(T v) {
  cout << "[";
  for (auto i : v) {
    cout << i << ", ";
  }
  cout << "\b\b]" << endl;
  return;
}
template <typename T>
void testV2(T v) {
  for (auto sv : v) {
    testV(sv);
  }
  cout << endl;
  return;
}
const ll MOD = 1e9 + 7;
V<ll> dp(1e7 + 10, -1);
ll rec(ll n) {
  if (n == 0) return 1;
  if (dp[n] >= 0) return dp[n];
  if (n & 1) {
    dp[n] = rec((n - 1) >> 1);
  } else {
    dp[n] = rec(n >> 1) + rec((n >> 1) - 1);
  }
  return dp[n];
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;
  cin >> N;
  if (N > 1e7) {
    terminate();
  }
  ll ans = 0;
  for (ll i = (0); i < (N + 1); i++) {
    ans += rec(i);
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}
