#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 9;
const long long mod = 998244353;
long long dp[maxn][2][2];
long long dfs(int n, int f1, int f2) {
  long long &Dp = dp[n][f1][f2];
  if (~Dp) return Dp;
  if (n == 1) {
    return Dp = (f1 == f2);
  } else if (n == 2) {
    return Dp = (f1 != f2);
  }
  if (n % 2) {
    int now;
    if (n / 2 % 2)
      now = !f1;
    else
      now = f1;
    if (now != f2) return Dp = 0;
    return Dp = dfs(n / 2, f1, !now) * dfs(n / 2, !now, now) % mod;
  } else {
    int L, R;
    if (n / 2 % 2) {
      L = f1, R = !f1;
    } else {
      L = !f1, R = f1;
    }
    if (L == f2) {
      Dp = dfs(n / 2 - 1, f1, !f2) * dfs(n / 2, !f2, f2) % mod;
    } else {
      Dp = dfs(n / 2, f1, !f2) * dfs(n / 2 - 1, !f2, f2) % mod;
    }
    return Dp;
  }
}
int main() {
  memset(dp, -1, sizeof dp);
  int n;
  cin >> n;
  long long ans = dfs(n, 1, n % 2);
  if (n % 2 == 0) ans = (ans + dfs(n, 1, 1)) % mod;
  cout << ans << endl;
}
