#include<iostream>
#include<queue>
using namespace std;
int k;
bool check(int x){
queue<int> q;
for(int i = 1;i <= k;i++){
q.push(1);
}
for(int j = 1;j <= k;j++){
q.push(0);
}
while(!q.empty()){
for(int j = 1;j < x;j++){
int now = q.front();
q.pop();
q.push(now);
}
if(q.front() == 1 and q.size() > k) return false;
else q.pop();
}
return true;
}
void f(){
for(int i = 1;;i++){
if(check(i)){
cout<<i;
break;
}
}
}
int main(){
cin>>k;
f();
}