#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
const double PI = acos(-1.0);
class modint {
 private:
  static const int64_t MOD = 1000000007;

 public:
  modint() { this->number = 0; }
  modint(const int64_t src) { this->number = opposit(src); }
  modint(const modint& src) { this->number = src.number; }
  modint& operator+=(const modint& obj) {
    this->number = san2(this->number + obj.number);
    return *this;
  }
  modint& operator-=(const modint& obj) {
    this->number = san2(this->number - obj.number + MOD);
    return *this;
  }
  modint& operator*=(const modint& obj) {
    this->number = (this->number * obj.number) % MOD;
    return *this;
  }
  modint& operator/=(const modint& obj) {
    this->number = (this->number * inverse(obj.number)) % MOD;
    return *this;
  }
  modint& operator+=(const int64_t n) {
    this->number = san2(this->number + opposit(n));
    return *this;
  }
  modint& operator-=(const int64_t n) {
    this->number = san2(this->number - opposit(n) + MOD);
    return *this;
  }
  modint& operator*=(const int64_t n) {
    this->number = (this->number * opposit(n)) % MOD;
    return *this;
  }
  modint& operator/=(const int64_t n) {
    this->number = (this->number * inverse(n)) % MOD;
    return *this;
  }
  modint operator+(const modint obj) {
    modint re(*this);
    return re += obj;
  }
  modint operator-(const modint obj) {
    modint re(*this);
    return re -= obj;
  }
  modint operator*(const modint obj) {
    modint re(*this);
    return re *= obj;
  }
  modint operator/(const modint obj) {
    modint re(*this);
    return re /= obj;
  }
  modint operator+(const int64_t n) {
    modint re(*this);
    return re += n;
  }
  modint operator-(const int64_t n) {
    modint re(*this);
    return re -= n;
  }
  modint operator*(const int64_t n) {
    modint re(*this);
    return re *= n;
  }
  modint operator/(const int64_t n) {
    modint re(*this);
    return re /= n;
  }
  modint operator=(const int64_t n) {
    this->number = opposit(n);
    return *this;
  }
  int64_t get() { return number; }

 private:
  int64_t number;
  int64_t opposit(int64_t n) {
    if (n < 0) n = MOD - ((-n) % MOD);
    return n % MOD;
  }
  int64_t inverse(int64_t n) {
    n = opposit(n);
    int64_t result = 1;
    for (int64_t i = MOD - 2; i; i /= 2) {
      if (i % 2) result = (result * n) % MOD;
      n = (n * n) % MOD;
    }
    return result;
  }
  inline int64_t san2(const int64_t n) { return MOD <= n ? n - MOD : n; }
  bool is_prime(int64_t n) {
    if (n <= 1) return false;
    if (n == 2) return true;
    if (n % 2 == 0) return false;
    const int64_t upperbound = int64_t(sqrt(n));
    for (int64_t i = 3; i <= upperbound; i += 2) {
      if (n % i == 0) return false;
    }
    return true;
  }
};
modint b(int64_t n) {
  if (n < 2) return n;
  if (n % 2 == 0) return b(n / 2);
  return b((n - 1) / 2) + b((n + 1) / 2);
}
modint a(int64_t n) { return b(n + 1) + (0 < n ? a(n - 1) : 0); }
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int64_t N;
  cin >> N;
  cout << a(N).get() << endl;
  return 0;
}
