#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
template <std::uint_fast64_t Modulus>
class modint {
  using u64 = std::uint_fast64_t;
  u64 a;

 public:
  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};
using mint = modint<1000000007>;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  vector<vector<mint>> dp(61, vector<mint>(n + 1, 0));
  dp[0][0] = 1;
  for (long long i = (0); i < (60); i++) {
    for (long long j = (0); j < (n + 1); j++) {
      dp[i + 1][j] += dp[i][j];
      if ((j + (1LL << i)) <= n) dp[i + 1][j + (1LL << i)] += dp[i][j];
      if ((j + (1LL << (i + 1))) <= n)
        dp[i + 1][j + (1LL << (i + 1))] += dp[i][j];
    }
  }
  mint ans = 0;
  for (long long i = (0); i < (n + 1); i++) ans += dp[60][i];
  cout << ans.value() << endl;
  return 0;
}
