#include<iostream>
using namespace std;
int main()
{
    bool ok=false;
    int  mas[100000],i,proiz=1,del=2,sb=0,m;
    double n;
    cin>>n;
    for(i=0;i<n;i++){

        mas[i]=i+1;
    }
   m=n;
    while(n>1){
        n/=del;
        proiz= proiz*del;


       del+=1;
    }
   proiz/=(del-1);

    while(sb<m){
        sb+=proiz;

    }

    cout<<mas[sb-proiz];
    return 0;
}
