#include <iostream> #include <vector> using namespace std; int main() { int n; while (cin >> n) { vector<int> vec; for (int i = 0; i < n; i++) { vec.push_back(i); } int flag = 1; int idx; int index = 0; while (true) { if (flag == 0) break; flag = 0; for (int i = 0; i < n; i++) { if (vec[i] != -1 && index == 2) { vec[i] = -1; index = 0; idx = i; } else if (vec[i] != -1) { index++; } } for (int i = 0; i < n; i++) { if (vec[i] >= 0) { flag = 1; break; } } } cout << idx << endl; } } // 64 位输出请用 printf("%lld")