#include <bits/stdc++.h>
using namespace std;
int n;
deque<int> D_Q;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
freopen("input.txt", "rt", stdin);
cin >> n;
for (int i = 1; i <= n; i++) {
D_Q.push_back(i);
}
while (D_Q.size() != 1) {
D_Q.pop_front();
int a = D_Q.front();
D_Q.pop_front();
D_Q.push_back(a);
}
cout << D_Q.front();
return 0;
}
deque는 원소를 front, back으로 삽입, 삭제할 수 있다.
ex) n = 6