#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 1E6 + 5;
const long long MOD = 998244353;
long long n;
long long f[MAXN][2];
long long dp(long long i, bool t) {
  long long& ret = f[i][t];
  if (ret != -1) return ret;
  if (i == 0) return ret = 1;
  long long root;
  if (i % 2 == 1) {
    root = (i + 1) / 2;
    if (root % 2 == t) {
      return ret = (dp(root - 1, 1 - t) * dp(i - root, (root + t) % 2)) % MOD;
    } else
      return ret = 0;
  } else {
    root = i / 2;
    if (root % 2 == t) {
      return ret = (dp(root - 1, 1 - t) * dp(i - root, (root + t) % 2)) % MOD;
    } else {
      root = i / 2 + 1;
      if (root % 2 == t) {
        return ret = (dp(root - 1, 1 - t) * dp(i - root, (root + t) % 2)) % MOD;
      } else
        return ret = 0;
    }
  }
}
signed main() {
  memset(f, -1, sizeof f);
  cin >> n;
  if (n % 2 == 0) {
    cout << (dp(n, 1) + dp(n, 0)) % MOD;
  } else
    cout << dp(n, ((n + 1) / 2) % 2);
}
