import java.util.Scanner;
import java.util.ArrayList;

public class Main {
  public static void main (String[] args) {
    ArrayList<Integer> perfectPowers = new ArrayList<Integer>();
    
    perfectPowers.add(1);
    
    for (int b = 2; b <= 1000; ++b) {
      int perfectPower = b * b;

      while (perfectPower <= 1000) {
        perfectPowers.add(perfectPower);
        perfectPower *= b;
      }
    }

    Scanner in = new Scanner(System.in);

    while (in.hasNext()) {
      int X = in.nextInt();
      int maxPerfectPower = Integer.MIN_VALUE;
      
      for (int i = 0; i < perfectPowers.size(); ++i) {
        if (perfectPowers.get(i) <= X) {
          maxPerfectPower = Math.max(maxPerfectPower, perfectPowers.get(i));
        }
      }

      System.out.println(maxPerfectPower);
    }
  }
} import java.util.Scanner; Scanner java.util import java.util.ArrayList; ArrayList java.util public class Main {
  public static void main (String[] args) {
    ArrayList<Integer> perfectPowers = new ArrayList<Integer>();
    
    perfectPowers.add(1);
    
    for (int b = 2; b <= 1000; ++b) {
      int perfectPower = b * b;

      while (perfectPower <= 1000) {
        perfectPowers.add(perfectPower);
        perfectPower *= b;
      }
    }

    Scanner in = new Scanner(System.in);

    while (in.hasNext()) {
      int X = in.nextInt();
      int maxPerfectPower = Integer.MIN_VALUE;
      
      for (int i = 0; i < perfectPowers.size(); ++i) {
        if (perfectPowers.get(i) <= X) {
          maxPerfectPower = Math.max(maxPerfectPower, perfectPowers.get(i));
        }
      }

      System.out.println(maxPerfectPower);
    }
  }
} Main public static void main (String[] args) {
    ArrayList<Integer> perfectPowers = new ArrayList<Integer>();
    
    perfectPowers.add(1);
    
    for (int b = 2; b <= 1000; ++b) {
      int perfectPower = b * b;

      while (perfectPower <= 1000) {
        perfectPowers.add(perfectPower);
        perfectPower *= b;
      }
    }

    Scanner in = new Scanner(System.in);

    while (in.hasNext()) {
      int X = in.nextInt();
      int maxPerfectPower = Integer.MIN_VALUE;
      
      for (int i = 0; i < perfectPowers.size(); ++i) {
        if (perfectPowers.get(i) <= X) {
          maxPerfectPower = Math.max(maxPerfectPower, perfectPowers.get(i));
        }
      }

      System.out.println(maxPerfectPower);
    }
  } main {
    ArrayList<Integer> perfectPowers = new ArrayList<Integer>();
    
    perfectPowers.add(1);
    
    for (int b = 2; b <= 1000; ++b) {
      int perfectPower = b * b;

      while (perfectPower <= 1000) {
        perfectPowers.add(perfectPower);
        perfectPower *= b;
      }
    }

    Scanner in = new Scanner(System.in);

    while (in.hasNext()) {
      int X = in.nextInt();
      int maxPerfectPower = Integer.MIN_VALUE;
      
      for (int i = 0; i < perfectPowers.size(); ++i) {
        if (perfectPowers.get(i) <= X) {
          maxPerfectPower = Math.max(maxPerfectPower, perfectPowers.get(i));
        }
      }

      System.out.println(maxPerfectPower);
    }
  } ArrayList<Integer> perfectPowers = new ArrayList<Integer>(); perfectPowers new ArrayList<Integer>() perfectPowers.add(1) perfectPowers.add perfectPowers 1 for (int b = 2; b <= 1000; ++b) {
      int perfectPower = b * b;

      while (perfectPower <= 1000) {
        perfectPowers.add(perfectPower);
        perfectPower *= b;
      }
    } int b = 2; int b = 2; b 2 b <= 1000 b 1000 ++b ++b b {
      int perfectPower = b * b;

      while (perfectPower <= 1000) {
        perfectPowers.add(perfectPower);
        perfectPower *= b;
      }
    } {
      int perfectPower = b * b;

      while (perfectPower <= 1000) {
        perfectPowers.add(perfectPower);
        perfectPower *= b;
      }
    } int perfectPower = b * b; perfectPower b * b b b while (perfectPower <= 1000) {
        perfectPowers.add(perfectPower);
        perfectPower *= b;
      } perfectPower <= 1000 perfectPower 1000 {
        perfectPowers.add(perfectPower);
        perfectPower *= b;
      } perfectPowers.add(perfectPower) perfectPowers.add perfectPowers perfectPower perfectPower *= b perfectPower b Scanner in = new Scanner(System.in); in new Scanner(System.in) while (in.hasNext()) {
      int X = in.nextInt();
      int maxPerfectPower = Integer.MIN_VALUE;
      
      for (int i = 0; i < perfectPowers.size(); ++i) {
        if (perfectPowers.get(i) <= X) {
          maxPerfectPower = Math.max(maxPerfectPower, perfectPowers.get(i));
        }
      }

      System.out.println(maxPerfectPower);
    } in.hasNext() in.hasNext in {
      int X = in.nextInt();
      int maxPerfectPower = Integer.MIN_VALUE;
      
      for (int i = 0; i < perfectPowers.size(); ++i) {
        if (perfectPowers.get(i) <= X) {
          maxPerfectPower = Math.max(maxPerfectPower, perfectPowers.get(i));
        }
      }

      System.out.println(maxPerfectPower);
    } int X = in.nextInt(); X in.nextInt() in.nextInt in int maxPerfectPower = Integer.MIN_VALUE; maxPerfectPower Integer.MIN_VALUE Integer Integer.MIN_VALUE for (int i = 0; i < perfectPowers.size(); ++i) {
        if (perfectPowers.get(i) <= X) {
          maxPerfectPower = Math.max(maxPerfectPower, perfectPowers.get(i));
        }
      } int i = 0; int i = 0; i 0 i < perfectPowers.size() i perfectPowers.size() perfectPowers.size perfectPowers ++i ++i i {
        if (perfectPowers.get(i) <= X) {
          maxPerfectPower = Math.max(maxPerfectPower, perfectPowers.get(i));
        }
      } {
        if (perfectPowers.get(i) <= X) {
          maxPerfectPower = Math.max(maxPerfectPower, perfectPowers.get(i));
        }
      } if (perfectPowers.get(i) <= X) {
          maxPerfectPower = Math.max(maxPerfectPower, perfectPowers.get(i));
        } perfectPowers.get(i) <= X perfectPowers.get(i) perfectPowers.get perfectPowers i X {
          maxPerfectPower = Math.max(maxPerfectPower, perfectPowers.get(i));
        } maxPerfectPower = Math.max(maxPerfectPower, perfectPowers.get(i)) maxPerfectPower Math.max(maxPerfectPower, perfectPowers.get(i)) Math.max Math maxPerfectPower perfectPowers.get(i) perfectPowers.get perfectPowers i System.out.println(maxPerfectPower) System.out.println System.out System System.out maxPerfectPower String[] args args public class Main {
  public static void main (String[] args) {
    ArrayList<Integer> perfectPowers = new ArrayList<Integer>();
    
    perfectPowers.add(1);
    
    for (int b = 2; b <= 1000; ++b) {
      int perfectPower = b * b;

      while (perfectPower <= 1000) {
        perfectPowers.add(perfectPower);
        perfectPower *= b;
      }
    }

    Scanner in = new Scanner(System.in);

    while (in.hasNext()) {
      int X = in.nextInt();
      int maxPerfectPower = Integer.MIN_VALUE;
      
      for (int i = 0; i < perfectPowers.size(); ++i) {
        if (perfectPowers.get(i) <= X) {
          maxPerfectPower = Math.max(maxPerfectPower, perfectPowers.get(i));
        }
      }

      System.out.println(maxPerfectPower);
    }
  }
} public class Main {
  public static void main (String[] args) {
    ArrayList<Integer> perfectPowers = new ArrayList<Integer>();
    
    perfectPowers.add(1);
    
    for (int b = 2; b <= 1000; ++b) {
      int perfectPower = b * b;

      while (perfectPower <= 1000) {
        perfectPowers.add(perfectPower);
        perfectPower *= b;
      }
    }

    Scanner in = new Scanner(System.in);

    while (in.hasNext()) {
      int X = in.nextInt();
      int maxPerfectPower = Integer.MIN_VALUE;
      
      for (int i = 0; i < perfectPowers.size(); ++i) {
        if (perfectPowers.get(i) <= X) {
          maxPerfectPower = Math.max(maxPerfectPower, perfectPowers.get(i));
        }
      }

      System.out.println(maxPerfectPower);
    }
  }
} Main
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
  public static void main (String[] args) {
    ArrayList<Integer> perfectPowers = new ArrayList<Integer>();
    
    perfectPowers.add(1);
    
    for (int b = 2; b <= 1000; ++b) {
      int perfectPower = b * b;

      while (perfectPower <= 1000) {
        perfectPowers.add(perfectPower);
        perfectPower *= b;
      }
    }

    Scanner in = new Scanner(System.in);

    while (in.hasNext()) {
      int X = in.nextInt();
      int maxPerfectPower = Integer.MIN_VALUE;
      
      for (int i = 0; i < perfectPowers.size(); ++i) {
        if (perfectPowers.get(i) <= X) {
          maxPerfectPower = Math.max(maxPerfectPower, perfectPowers.get(i));
        }
      }

      System.out.println(maxPerfectPower);
    }
  }
}