#include using namespace std; int main() { cin.tie(0); cout.tie(0); ios::sync_with_stdio(false); int N; cin >> N; if(N < 3) { cout << 0 << '\n'; } else { for(int i = 2; ;i++) { if(N % i > 0) { cout << N - 1 - i << '\n'; return 0; } } } return 0; }