#include <bits/stdc++.h> using namespace std; int main (){ ios::sync_with_stdio(false); cin.tie(0); int n; while (cin >> n){ cout << (pow(2, n - 1) + 1) % n; } return 0; }