#include<bits/stdc++.h> using namespace std; long long n,a,b,s1,s2; int main() { cin>>n; a=sqrt(n); b=n-a*(a-1); s1=pow(a,a-1)*b; if(b>=2*a-1) s1=pow(a,a)*(b-a); cout<<s1; }