"use strict";
    
const main = arg => {
    const N = parseInt(arg.split("\n")[0]);
    
    for(let i=N; i>0; i--) {
        let primes = primeFactorization(i);
        let set    = new Set(primes);
        
        if(primes.length % 2 === 0 && set.size === 1) {
            console.log(i);
            return;
        }
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

function primeFactorization(n) {
    let result = [];

    if (n === 1) {
        return [1];
    }

    let init = 2;

    while ( n !== 1 ) {
        let i = init;
        while (i < Number.MAX_SAFE_INTEGER) {
            if (n % i == 0) {
                result.push(i)
                n /= i;
                break;
            }
            i++;
        }
        init = i;
    }
    return result;
}
