#include <bits/stdc++.h>
using namespace std;
#define task "SHT"
int main()
{
freopen(task ".inp","r",stdin);
freopen(task ".out", "w", stdout);
   long long n,d=0; cin>>n;
   for (long long a=1;a<=n-1;a++)
   {
   for (long long i=1; i<=a/2; i++)
    if (n%i==0) d=d+i;
    if (a==d) {cout <<a; break;}
}
}
