#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <fstream>
#include <queue>
#define rep(i, l, r) for(int i = l; i <= r; i++)
#define down(i, l, r) for(int i = l; i >= r; i--)
#define MS 34567
#define MAX 1037471823
using namespace std;
int k[11], n;
long long ans, ansm;
void Search(long long m, long long s, int o, int l)
{
if (ansm < s || (ansm == s && ans > m)) ans = m, ansm = s; long long a = 1; int b = 1;
if (o == 11) return;
while(m*a <= n && b <= l)
{
Search(m*a, s*b, o+1, b);
a *= k[o]; b++;
}
}
int main()
{
scanf("%d", &n); ans = ansm = 0;
k[1] = 2, k[2] = 3, k[3] = 5, k[4] = 7, k[5] = 11, k[6] = 13, k[7] = 17, k[8] = 19, k[9] = 23, k[10] = 27;
Search(1, 1, 1, 999);
printf("%lld\n", ans);
return 0;
}
I2luY2x1ZGUgPGNzdHJpbmc+CiNpbmNsdWRlIDxjbWF0aD4KI2luY2x1ZGUgPGFsZ29yaXRobT4KI2luY2x1ZGUgPGNzdGRsaWI+CiNpbmNsdWRlIDxjc3RkaW8+CiNpbmNsdWRlIDxpb3N0cmVhbT4KI2luY2x1ZGUgPGZzdHJlYW0+CiNpbmNsdWRlIDxxdWV1ZT4KCiNkZWZpbmUgcmVwKGksIGwsIHIpIGZvcihpbnQgaSA9IGw7IGkgPD0gcjsgaSsrKQojZGVmaW5lIGRvd24oaSwgbCwgcikgZm9yKGludCBpID0gbDsgaSA+PSByOyBpLS0pCiNkZWZpbmUgTVMgMzQ1NjcKI2RlZmluZSBNQVggMTAzNzQ3MTgyMwoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBrWzExXSwgbjsKbG9uZyBsb25nIGFucywgYW5zbTsKCnZvaWQgU2VhcmNoKGxvbmcgbG9uZyBtLCBsb25nIGxvbmcgcywgaW50IG8sIGludCBsKQp7CglpZiAoYW5zbSA8IHMgfHwgKGFuc20gPT0gcyAmJiBhbnMgPiBtKSkgYW5zID0gbSwgYW5zbSA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