#include <iostream>
using namespace std;
class card {
int f;
int b;
int *arr;
public:
card(int n) {
f = 0;
b = -1;
arr = new int[n];
}
void push(int n) {
arr[++b] = n;
}
int pop() {
if (empty()) return -1;
return arr[f++];
}
int size() {
return b - f + 1;
}
int empty() {
return (b - f) == -1;
}
~card() {
delete[] arr;
}
};
int main(void)
{
ios_base::sync_with_stdio(false); cin.tie(NULL);
int n;
cin >> n;
card q(n * 2);
for (int i = 1; i <= n; i++) q.push(i);
while (q.size() != 1)
{
q.pop();
q.push(q.pop());
}
cout << q.pop();
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmNsYXNzIGNhcmQgewoJaW50IGY7CglpbnQgYjsKCWludCAqYXJyOwpwdWJsaWM6CgljYXJkKGludCBuKSB7CgkJZiA9IDA7CgkJYiA9IC0xOwoJCWFyciA9IG5ldyBpbnRbbl07Cgl9Cgl2b2lkIHB1c2goaW50IG4pIHsKCQlhcnJbKytiXSA9IG47Cgl9CglpbnQgcG9wKCkgewoJCWlmIChlbXB0eSgpKSByZXR1cm4gLTE7CgkJcmV0dXJuIGFycltmKytdOwoJfQoJaW50IHNpemUoKSB7CgkJcmV0dXJuIGIgLSBmICsgMTsKCX0KCWludCBlbXB0eSgpIHsKCQlyZXR1cm4gKGIgLSBmKSA9PSAtMTsKCX0KCX5jYXJkKCkgewoJCWRlbGV0ZVtdIGFycjsKCX0KfTsKaW50IG1haW4odm9pZCkKewoJaW9zX2Jhc2U6OnN5bmNfd2l0aF9zdGRpbyhmYWxzZSk7IGNpbi50aWUoTlVMTCk7CglpbnQgbjsKCWNpbiA+PiBuOwoKCWNhcmQgcShuICogMik7CgoJZm9yIChpbnQgaSA9IDE7IGkgPD0gbjsgaSsrKSBxLnB1c2goaSk7CgoJd2hpbGUgKHEuc2l6ZSgpICE9IDEpCgl7CgkJcS5wb3AoKTsKCQlxLnB1c2gocS5wb3AoKSk7Cgl9Cgljb3V0IDw8IHEucG9wKCk7Cn0=