import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);

    String s;
    String sl[];
    s = r.readLine();
    sl = s.split(" ");
    
    int v[] = new int[1234];

    int x = Integer.parseInt(sl[0]);
    
    v[1] = 1;
    for(int i = 2; i <= 1000; i++)
    {
      for(int j = i * i; j <= 1000; j *= i)
      {
        v[j] = 1;
      }
    }
    
    for(int i = x; ; i--)
    {
      if(v[i] == 1)
      {
        System.out.println(i);
        System.exit(0);
      }
    }

  }

} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main
{

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);

    String s;
    String sl[];
    s = r.readLine();
    sl = s.split(" ");
    
    int v[] = new int[1234];

    int x = Integer.parseInt(sl[0]);
    
    v[1] = 1;
    for(int i = 2; i <= 1000; i++)
    {
      for(int j = i * i; j <= 1000; j *= i)
      {
        v[j] = 1;
      }
    }
    
    for(int i = x; ; i--)
    {
      if(v[i] == 1)
      {
        System.out.println(i);
        System.exit(0);
      }
    }

  }

} Main public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);

    String s;
    String sl[];
    s = r.readLine();
    sl = s.split(" ");
    
    int v[] = new int[1234];

    int x = Integer.parseInt(sl[0]);
    
    v[1] = 1;
    for(int i = 2; i <= 1000; i++)
    {
      for(int j = i * i; j <= 1000; j *= i)
      {
        v[j] = 1;
      }
    }
    
    for(int i = x; ; i--)
    {
      if(v[i] == 1)
      {
        System.out.println(i);
        System.exit(0);
      }
    }

  } main {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);

    String s;
    String sl[];
    s = r.readLine();
    sl = s.split(" ");
    
    int v[] = new int[1234];

    int x = Integer.parseInt(sl[0]);
    
    v[1] = 1;
    for(int i = 2; i <= 1000; i++)
    {
      for(int j = i * i; j <= 1000; j *= i)
      {
        v[j] = 1;
      }
    }
    
    for(int i = x; ; i--)
    {
      if(v[i] == 1)
      {
        System.out.println(i);
        System.exit(0);
      }
    }

  } BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1); r new BufferedReader(new InputStreamReader(System.in), 1) String s; s String sl[]; sl s = r.readLine() s r.readLine() r.readLine r sl = s.split(" ") sl s.split(" ") s.split s " " int v[] = new int[1234]; v new int[1234] 1234 int x = Integer.parseInt(sl[0]); x Integer.parseInt(sl[0]) Integer.parseInt Integer sl[0] sl 0 v[1] = 1 v[1] v 1 1 for(int i = 2; i <= 1000; i++)
    {
      for(int j = i * i; j <= 1000; j *= i)
      {
        v[j] = 1;
      }
    } int i = 2; int i = 2; i 2 i <= 1000 i 1000 i++ i++ i {
      for(int j = i * i; j <= 1000; j *= i)
      {
        v[j] = 1;
      }
    } {
      for(int j = i * i; j <= 1000; j *= i)
      {
        v[j] = 1;
      }
    } for(int j = i * i; j <= 1000; j *= i)
      {
        v[j] = 1;
      } int j = i * i; int j = i * i; j i * i i i j <= 1000 j 1000 j *= i j *= i j i {
        v[j] = 1;
      } {
        v[j] = 1;
      } v[j] = 1 v[j] v j 1 for(int i = x; ; i--)
    {
      if(v[i] == 1)
      {
        System.out.println(i);
        System.exit(0);
      }
    } int i = x; int i = x; i x i-- i-- i {
      if(v[i] == 1)
      {
        System.out.println(i);
        System.exit(0);
      }
    } {
      if(v[i] == 1)
      {
        System.out.println(i);
        System.exit(0);
      }
    } if(v[i] == 1)
      {
        System.out.println(i);
        System.exit(0);
      } v[i] == 1 v[i] v i 1 {
        System.out.println(i);
        System.exit(0);
      } System.out.println(i) System.out.println System.out System System.out i System.exit(0) System.exit System 0 String[] args args public class Main
{

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);

    String s;
    String sl[];
    s = r.readLine();
    sl = s.split(" ");
    
    int v[] = new int[1234];

    int x = Integer.parseInt(sl[0]);
    
    v[1] = 1;
    for(int i = 2; i <= 1000; i++)
    {
      for(int j = i * i; j <= 1000; j *= i)
      {
        v[j] = 1;
      }
    }
    
    for(int i = x; ; i--)
    {
      if(v[i] == 1)
      {
        System.out.println(i);
        System.exit(0);
      }
    }

  }

} public class Main
{

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);

    String s;
    String sl[];
    s = r.readLine();
    sl = s.split(" ");
    
    int v[] = new int[1234];

    int x = Integer.parseInt(sl[0]);
    
    v[1] = 1;
    for(int i = 2; i <= 1000; i++)
    {
      for(int j = i * i; j <= 1000; j *= i)
      {
        v[j] = 1;
      }
    }
    
    for(int i = x; ; i--)
    {
      if(v[i] == 1)
      {
        System.out.println(i);
        System.exit(0);
      }
    }

  }

} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);

    String s;
    String sl[];
    s = r.readLine();
    sl = s.split(" ");
    
    int v[] = new int[1234];

    int x = Integer.parseInt(sl[0]);
    
    v[1] = 1;
    for(int i = 2; i <= 1000; i++)
    {
      for(int j = i * i; j <= 1000; j *= i)
      {
        v[j] = 1;
      }
    }
    
    for(int i = x; ; i--)
    {
      if(v[i] == 1)
      {
        System.out.println(i);
        System.exit(0);
      }
    }

  }

}