#include <bits/stdc++.h>
using namespace std;
const int N = 2000000;
const int mod = 998244353;
int used[N][2];
int f[N][2];
bool ok[N];
int solve(int n, int k) {
  if (used[n][k]) {
    return f[n][k];
  }
  if (!ok[n]) {
    return 0;
  }
  int last = 0;
  int m = n;
  int j = 0;
  for (int i = 0; i < 40; i++) {
    if ((1 << i) > m) {
      last = m;
      break;
    }
    j = i;
    m -= (1 << i);
  }
  if (m == 0) {
    used[n][k] = 1;
    f[n][k] = 0;
    return 0;
  }
  int ans = 0;
  int nxt = (1 << j);
  int sz = (n - last) / 2;
  for (int i = max(0, last - sz - 1); i <= min(last, sz + 1); i++) {
    if ((sz + i) % 2 != k) {
      continue;
    }
    ans += 1ll * (solve(sz + i, 0) + solve(sz + i, 1)) % mod *
           solve(sz + last - i, 1) % mod;
    if (ans >= mod) {
      ans -= mod;
    }
  }
  used[n][k] = 1;
  f[n][k] = ans;
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  int x = 1;
  int v = 0;
  while (x <= n) {
    ok[x] = 1;
    ok[x + 1] = 1;
    x++;
    x = x * 2 - v;
    v = 1 - v;
  }
  used[0][0] = 1;
  f[0][0] = 1;
  used[0][1] = 1;
  f[0][1] = 1;
  used[1][0] = 1;
  f[1][0] = 1;
  used[1][1] = 1;
  f[1][1] = 0;
  cout << (solve(n, 0) + solve(n, 1)) % mod << "\n";
  return 0;
}
