#include <bits/stdc++.h>
using namespace std;
long long gcd(long long x, long long y) { return y == 0 ? x : gcd(y, x % y); }
int main() {
  long long n, ans, tot, j;
  cin >> n, ans = n;
  for (long long i = n; ((i - 3) * i + 2) * i > ans; i--) {
    tot = i * i - i;
    for (j = i - 1; gcd(tot, j) != 1; j--)
      ;
    ans = max(ans, tot * j);
  }
  cout << ans << '\n';
  return 0;
}
