import java.io.*;
import java.util.*;

public class Main{
	public static InputReader scn = new InputReader();
	public static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) throws Exception {
		//System.out.println("GO");

		int[] div = new int[1001];
		div[1] = 1;
		for (int i = 2; i <= 1e3; i++) {
			if (div[i] == 0) {
				for (int j = i; j <= 1e3; j += i) {
					div[j] = i;
				}
			}
		}

		int n = scn.nextInt();
		for (int i = n; i > 1; i--) {
			if(i == 980) {
				out.println(i);
			}
			HashMap<Integer, Integer> map = new HashMap<>();
			int k = i;
			while (k != 1) {
				if (map.containsKey(div[k])) {
					map.put(div[k], map.get(div[k]) + 1);
				} else {
					map.put(div[k], 1);
				}
				k /= div[k];
			}

			int z = -1;
			for (int x : map.keySet()) {
				if (z == -1) {
					z = map.get(x);
				} else if (map.get(x) != z) {
					z = -2;
				}
			}

			if (z > 1) {
				System.out.println(i);
				return;
			}
		}
		out.println(1);
		out.flush();
	}

	public static class InputReader {
		InputStream is;

		public InputReader() {
			is = System.in;
		}

		byte[] inbuf = new byte[1024];
		public int lenbuf = 0, ptrbuf = 0;

		int readByte() {
			if (lenbuf == -1)
				throw new InputMismatchException();
			if (ptrbuf >= lenbuf) {
				ptrbuf = 0;
				try {
					lenbuf = is.read(inbuf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return -1;
			}
			return inbuf[ptrbuf++];
		}

		boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		int skip() {
			int b;
			while ((b = readByte()) != -1 && isSpaceChar(b))
				;
			return b;
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		char nextChar() {
			return (char) skip();
		}

		String next() {
			int b = skip();
			StringBuilder sb = new StringBuilder();
			while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		char[] next(int n) {
			char[] buf = new char[n];
			int b = skip(), p = 0;
			while (p < n && !(isSpaceChar(b))) {
				buf[p++] = (char) b;
				b = readByte();
			}
			return n == p ? buf : Arrays.copyOf(buf, p);
		}

		char[][] nextMatrix(int n, int m) {
			char[][] map = new char[n][];
			for (int i = 0; i < n; i++)
				map[i] = next(m);
			return map;
		}

		int[] nextArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		int nextInt() {
			int num = 0, b;
			boolean minus = false;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}

			while (true) {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		}

		long nextLong() {
			long num = 0;
			int b;
			boolean minus = false;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}

			while (true) {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		}
	}
} import java.io.*; io.* java import java.util.*; util.* java public class Main{
	public static InputReader scn = new InputReader();
	public static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) throws Exception {
		//System.out.println("GO");

		int[] div = new int[1001];
		div[1] = 1;
		for (int i = 2; i <= 1e3; i++) {
			if (div[i] == 0) {
				for (int j = i; j <= 1e3; j += i) {
					div[j] = i;
				}
			}
		}

		int n = scn.nextInt();
		for (int i = n; i > 1; i--) {
			if(i == 980) {
				out.println(i);
			}
			HashMap<Integer, Integer> map = new HashMap<>();
			int k = i;
			while (k != 1) {
				if (map.containsKey(div[k])) {
					map.put(div[k], map.get(div[k]) + 1);
				} else {
					map.put(div[k], 1);
				}
				k /= div[k];
			}

			int z = -1;
			for (int x : map.keySet()) {
				if (z == -1) {
					z = map.get(x);
				} else if (map.get(x) != z) {
					z = -2;
				}
			}

			if (z > 1) {
				System.out.println(i);
				return;
			}
		}
		out.println(1);
		out.flush();
	}

	public static class InputReader {
		InputStream is;

		public InputReader() {
			is = System.in;
		}

		byte[] inbuf = new byte[1024];
		public int lenbuf = 0, ptrbuf = 0;

		int readByte() {
			if (lenbuf == -1)
				throw new InputMismatchException();
			if (ptrbuf >= lenbuf) {
				ptrbuf = 0;
				try {
					lenbuf = is.read(inbuf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return -1;
			}
			return inbuf[ptrbuf++];
		}

		boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		int skip() {
			int b;
			while ((b = readByte()) != -1 && isSpaceChar(b))
				;
			return b;
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		char nextChar() {
			return (char) skip();
		}

		String next() {
			int b = skip();
			StringBuilder sb = new StringBuilder();
			while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		char[] next(int n) {
			char[] buf = new char[n];
			int b = skip(), p = 0;
			while (p < n && !(isSpaceChar(b))) {
				buf[p++] = (char) b;
				b = readByte();
			}
			return n == p ? buf : Arrays.copyOf(buf, p);
		}

		char[][] nextMatrix(int n, int m) {
			char[][] map = new char[n][];
			for (int i = 0; i < n; i++)
				map[i] = next(m);
			return map;
		}

		int[] nextArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		int nextInt() {
			int num = 0, b;
			boolean minus = false;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}

			while (true) {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		}

		long nextLong() {
			long num = 0;
			int b;
			boolean minus = false;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}

			while (true) {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		}
	}
} Main public static InputReader scn = new InputReader(); scn new InputReader() public static PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) public static void main(String[] args) throws Exception {
		//System.out.println("GO");

		int[] div = new int[1001];
		div[1] = 1;
		for (int i = 2; i <= 1e3; i++) {
			if (div[i] == 0) {
				for (int j = i; j <= 1e3; j += i) {
					div[j] = i;
				}
			}
		}

		int n = scn.nextInt();
		for (int i = n; i > 1; i--) {
			if(i == 980) {
				out.println(i);
			}
			HashMap<Integer, Integer> map = new HashMap<>();
			int k = i;
			while (k != 1) {
				if (map.containsKey(div[k])) {
					map.put(div[k], map.get(div[k]) + 1);
				} else {
					map.put(div[k], 1);
				}
				k /= div[k];
			}

			int z = -1;
			for (int x : map.keySet()) {
				if (z == -1) {
					z = map.get(x);
				} else if (map.get(x) != z) {
					z = -2;
				}
			}

			if (z > 1) {
				System.out.println(i);
				return;
			}
		}
		out.println(1);
		out.flush();
	} main {
		//System.out.println("GO");

		int[] div = new int[1001];
		div[1] = 1;
		for (int i = 2; i <= 1e3; i++) {
			if (div[i] == 0) {
				for (int j = i; j <= 1e3; j += i) {
					div[j] = i;
				}
			}
		}

		int n = scn.nextInt();
		for (int i = n; i > 1; i--) {
			if(i == 980) {
				out.println(i);
			}
			HashMap<Integer, Integer> map = new HashMap<>();
			int k = i;
			while (k != 1) {
				if (map.containsKey(div[k])) {
					map.put(div[k], map.get(div[k]) + 1);
				} else {
					map.put(div[k], 1);
				}
				k /= div[k];
			}

			int z = -1;
			for (int x : map.keySet()) {
				if (z == -1) {
					z = map.get(x);
				} else if (map.get(x) != z) {
					z = -2;
				}
			}

			if (z > 1) {
				System.out.println(i);
				return;
			}
		}
		out.println(1);
		out.flush();
	} int[] div = new int[1001]; div new int[1001] 1001 div[1] = 1 div[1] div 1 1 for (int i = 2; i <= 1e3; i++) {
			if (div[i] == 0) {
				for (int j = i; j <= 1e3; j += i) {
					div[j] = i;
				}
			}
		} int i = 2; int i = 2; i 2 i <= 1e3 i 1e3 i++ i++ i {
			if (div[i] == 0) {
				for (int j = i; j <= 1e3; j += i) {
					div[j] = i;
				}
			}
		} {
			if (div[i] == 0) {
				for (int j = i; j <= 1e3; j += i) {
					div[j] = i;
				}
			}
		} if (div[i] == 0) {
				for (int j = i; j <= 1e3; j += i) {
					div[j] = i;
				}
			} div[i] == 0 div[i] div i 0 {
				for (int j = i; j <= 1e3; j += i) {
					div[j] = i;
				}
			} for (int j = i; j <= 1e3; j += i) {
					div[j] = i;
				} int j = i; int j = i; j i j <= 1e3 j 1e3 j += i j += i j i {
					div[j] = i;
				} {
					div[j] = i;
				} div[j] = i div[j] div j i int n = scn.nextInt(); n scn.nextInt() scn.nextInt scn for (int i = n; i > 1; i--) {
			if(i == 980) {
				out.println(i);
			}
			HashMap<Integer, Integer> map = new HashMap<>();
			int k = i;
			while (k != 1) {
				if (map.containsKey(div[k])) {
					map.put(div[k], map.get(div[k]) + 1);
				} else {
					map.put(div[k], 1);
				}
				k /= div[k];
			}

			int z = -1;
			for (int x : map.keySet()) {
				if (z == -1) {
					z = map.get(x);
				} else if (map.get(x) != z) {
					z = -2;
				}
			}

			if (z > 1) {
				System.out.println(i);
				return;
			}
		} int i = n; int i = n; i n i > 1 i 1 i-- i-- i {
			if(i == 980) {
				out.println(i);
			}
			HashMap<Integer, Integer> map = new HashMap<>();
			int k = i;
			while (k != 1) {
				if (map.containsKey(div[k])) {
					map.put(div[k], map.get(div[k]) + 1);
				} else {
					map.put(div[k], 1);
				}
				k /= div[k];
			}

			int z = -1;
			for (int x : map.keySet()) {
				if (z == -1) {
					z = map.get(x);
				} else if (map.get(x) != z) {
					z = -2;
				}
			}

			if (z > 1) {
				System.out.println(i);
				return;
			}
		} {
			if(i == 980) {
				out.println(i);
			}
			HashMap<Integer, Integer> map = new HashMap<>();
			int k = i;
			while (k != 1) {
				if (map.containsKey(div[k])) {
					map.put(div[k], map.get(div[k]) + 1);
				} else {
					map.put(div[k], 1);
				}
				k /= div[k];
			}

			int z = -1;
			for (int x : map.keySet()) {
				if (z == -1) {
					z = map.get(x);
				} else if (map.get(x) != z) {
					z = -2;
				}
			}

			if (z > 1) {
				System.out.println(i);
				return;
			}
		} if(i == 980) {
				out.println(i);
			} i == 980 i 980 {
				out.println(i);
			} out.println(i) out.println out i HashMap<Integer, Integer> map = new HashMap<>(); map new HashMap<>() int k = i; k i while (k != 1) {
				if (map.containsKey(div[k])) {
					map.put(div[k], map.get(div[k]) + 1);
				} else {
					map.put(div[k], 1);
				}
				k /= div[k];
			} k != 1 k 1 {
				if (map.containsKey(div[k])) {
					map.put(div[k], map.get(div[k]) + 1);
				} else {
					map.put(div[k], 1);
				}
				k /= div[k];
			} if (map.containsKey(div[k])) {
					map.put(div[k], map.get(div[k]) + 1);
				} else {
					map.put(div[k], 1);
				} map.containsKey(div[k]) map.containsKey map div[k] div k {
					map.put(div[k], map.get(div[k]) + 1);
				} map.put(div[k], map.get(div[k]) + 1) map.put map div[k] div k map.get(div[k]) + 1 map.get(div[k]) map.get map div[k] div k 1 {
					map.put(div[k], 1);
				} map.put(div[k], 1) map.put map div[k] div k 1 k /= div[k] k div[k] div k int z = -1; z -1 1 for (int x : map.keySet()) {
				if (z == -1) {
					z = map.get(x);
				} else if (map.get(x) != z) {
					z = -2;
				}
			} int x map.keySet() map.keySet map {
				if (z == -1) {
					z = map.get(x);
				} else if (map.get(x) != z) {
					z = -2;
				}
			} {
				if (z == -1) {
					z = map.get(x);
				} else if (map.get(x) != z) {
					z = -2;
				}
			} if (z == -1) {
					z = map.get(x);
				} else if (map.get(x) != z) {
					z = -2;
				} z == -1 z -1 1 {
					z = map.get(x);
				} z = map.get(x) z map.get(x) map.get map x if (map.get(x) != z) {
					z = -2;
				} map.get(x) != z map.get(x) map.get map x z {
					z = -2;
				} z = -2 z -2 2 if (z > 1) {
				System.out.println(i);
				return;
			} z > 1 z 1 {
				System.out.println(i);
				return;
			} System.out.println(i) System.out.println System.out System System.out i return; out.println(1) out.println out 1 out.flush() out.flush out String[] args args public static class InputReader {
		InputStream is;

		public InputReader() {
			is = System.in;
		}

		byte[] inbuf = new byte[1024];
		public int lenbuf = 0, ptrbuf = 0;

		int readByte() {
			if (lenbuf == -1)
				throw new InputMismatchException();
			if (ptrbuf >= lenbuf) {
				ptrbuf = 0;
				try {
					lenbuf = is.read(inbuf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return -1;
			}
			return inbuf[ptrbuf++];
		}

		boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		int skip() {
			int b;
			while ((b = readByte()) != -1 && isSpaceChar(b))
				;
			return b;
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		char nextChar() {
			return (char) skip();
		}

		String next() {
			int b = skip();
			StringBuilder sb = new StringBuilder();
			while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		char[] next(int n) {
			char[] buf = new char[n];
			int b = skip(), p = 0;
			while (p < n && !(isSpaceChar(b))) {
				buf[p++] = (char) b;
				b = readByte();
			}
			return n == p ? buf : Arrays.copyOf(buf, p);
		}

		char[][] nextMatrix(int n, int m) {
			char[][] map = new char[n][];
			for (int i = 0; i < n; i++)
				map[i] = next(m);
			return map;
		}

		int[] nextArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		int nextInt() {
			int num = 0, b;
			boolean minus = false;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}

			while (true) {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		}

		long nextLong() {
			long num = 0;
			int b;
			boolean minus = false;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}

			while (true) {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		}
	} InputReader InputStream is; is byte[] inbuf = new byte[1024]; inbuf new byte[1024] 1024 public int lenbuf = 0 lenbuf 0 ptrbuf = 0; ptrbuf 0 public InputReader() {
			is = System.in;
		} InputReader {
			is = System.in;
		} is = System.in is System.in System System.in int readByte() {
			if (lenbuf == -1)
				throw new InputMismatchException();
			if (ptrbuf >= lenbuf) {
				ptrbuf = 0;
				try {
					lenbuf = is.read(inbuf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return -1;
			}
			return inbuf[ptrbuf++];
		} readByte {
			if (lenbuf == -1)
				throw new InputMismatchException();
			if (ptrbuf >= lenbuf) {
				ptrbuf = 0;
				try {
					lenbuf = is.read(inbuf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return -1;
			}
			return inbuf[ptrbuf++];
		} if (lenbuf == -1)
				throw new InputMismatchException(); lenbuf == -1 lenbuf -1 1 throw new InputMismatchException(); new InputMismatchException() if (ptrbuf >= lenbuf) {
				ptrbuf = 0;
				try {
					lenbuf = is.read(inbuf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return -1;
			} ptrbuf >= lenbuf ptrbuf lenbuf {
				ptrbuf = 0;
				try {
					lenbuf = is.read(inbuf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return -1;
			} ptrbuf = 0 ptrbuf 0 try {
					lenbuf = is.read(inbuf);
				} catch (IOException e) {
					throw new InputMismatchException();
				} catch (IOException e) {
					throw new InputMismatchException();
				} IOException e {
					throw new InputMismatchException();
				} throw new InputMismatchException(); new InputMismatchException() {
					lenbuf = is.read(inbuf);
				} lenbuf = is.read(inbuf) lenbuf is.read(inbuf) is.read is inbuf if (lenbuf <= 0)
					return -1; lenbuf <= 0 lenbuf 0 return -1; -1 1 return inbuf[ptrbuf++]; inbuf[ptrbuf++] inbuf ptrbuf++ ptrbuf boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		} isSpaceChar {
			return !(c >= 33 && c <= 126);
		} return !(c >= 33 && c <= 126); !(c >= 33 && c <= 126) (c >= 33 && c <= 126) c >= 33 c 33 c <= 126 c 126 int c c int skip() {
			int b;
			while ((b = readByte()) != -1 && isSpaceChar(b))
				;
			return b;
		} skip {
			int b;
			while ((b = readByte()) != -1 && isSpaceChar(b))
				;
			return b;
		} int b; b while ((b = readByte()) != -1 && isSpaceChar(b))
				; (b = readByte()) != -1 && isSpaceChar(b) (b = readByte()) != -1 (b = readByte()) b readByte() readByte -1 1 isSpaceChar(b) isSpaceChar b return b; b double nextDouble() {
			return Double.parseDouble(next());
		} nextDouble {
			return Double.parseDouble(next());
		} return Double.parseDouble(next()); Double.parseDouble(next()) Double.parseDouble Double next() next char nextChar() {
			return (char) skip();
		} nextChar {
			return (char) skip();
		} return (char) skip(); (char) skip() skip String next() {
			int b = skip();
			StringBuilder sb = new StringBuilder();
			while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		} next {
			int b = skip();
			StringBuilder sb = new StringBuilder();
			while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		} int b = skip(); b skip() skip StringBuilder sb = new StringBuilder(); sb new StringBuilder() while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
				sb.appendCodePoint(b);
				b = readByte();
			} !(isSpaceChar(b)) (isSpaceChar(b)) isSpaceChar b { // when nextLine, (isSpaceChar(b) && b != ' ')
				sb.appendCodePoint(b);
				b = readByte();
			} sb.appendCodePoint(b) sb.appendCodePoint sb b b = readByte() b readByte() readByte return sb.toString(); sb.toString() sb.toString sb char[] next(int n) {
			char[] buf = new char[n];
			int b = skip(), p = 0;
			while (p < n && !(isSpaceChar(b))) {
				buf[p++] = (char) b;
				b = readByte();
			}
			return n == p ? buf : Arrays.copyOf(buf, p);
		} next {
			char[] buf = new char[n];
			int b = skip(), p = 0;
			while (p < n && !(isSpaceChar(b))) {
				buf[p++] = (char) b;
				b = readByte();
			}
			return n == p ? buf : Arrays.copyOf(buf, p);
		} char[] buf = new char[n]; buf new char[n] n int b = skip() b skip() skip p = 0; p 0 while (p < n && !(isSpaceChar(b))) {
				buf[p++] = (char) b;
				b = readByte();
			} p < n && !(isSpaceChar(b)) p < n p n !(isSpaceChar(b)) (isSpaceChar(b)) isSpaceChar b {
				buf[p++] = (char) b;
				b = readByte();
			} buf[p++] = (char) b buf[p++] buf p++ p (char) b b = readByte() b readByte() readByte return n == p ? buf : Arrays.copyOf(buf, p); n == p ? buf : Arrays.copyOf(buf, p) n == p n p buf Arrays.copyOf(buf, p) Arrays.copyOf Arrays buf p int n n char[][] nextMatrix(int n, int m) {
			char[][] map = new char[n][];
			for (int i = 0; i < n; i++)
				map[i] = next(m);
			return map;
		} nextMatrix {
			char[][] map = new char[n][];
			for (int i = 0; i < n; i++)
				map[i] = next(m);
			return map;
		} char[][] map = new char[n][]; map new char[n][] n for (int i = 0; i < n; i++)
				map[i] = next(m); int i = 0; int i = 0; i 0 i < n i n i++ i++ i map[i] = next(m); map[i] = next(m) map[i] map i next(m) next m return map; map int n n int m m int[] nextArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		} nextArray {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		} int[] a = new int[n]; a new int[n] n for (int i = 0; i < n; i++)
				a[i] = nextInt(); int i = 0; int i = 0; i 0 i < n i n i++ i++ i a[i] = nextInt(); a[i] = nextInt() a[i] a i nextInt() nextInt return a; a int n n int nextInt() {
			int num = 0, b;
			boolean minus = false;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}

			while (true) {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		} nextInt {
			int num = 0, b;
			boolean minus = false;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}

			while (true) {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		} int num = 0 num 0 b; b boolean minus = false; minus false while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				; (b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-') (b = readByte()) != -1 (b = readByte()) b readByte() readByte -1 1 !((b >= '0' && b <= '9') || b == '-') ((b >= '0' && b <= '9') || b == '-') (b >= '0' && b <= '9') b >= '0' b '0' b <= '9' b '9' b == '-' b '-' if (b == '-') {
				minus = true;
				b = readByte();
			} b == '-' b '-' {
				minus = true;
				b = readByte();
			} minus = true minus true b = readByte() b readByte() readByte while (true) {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			} true {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			} if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				} b >= '0' && b <= '9' b >= '0' b '0' b <= '9' b '9' {
					num = num * 10 + (b - '0');
				} num = num * 10 + (b - '0') num num * 10 + (b - '0') num * 10 num 10 (b - '0') b '0' {
					return minus ? -num : num;
				} return minus ? -num : num; minus ? -num : num minus -num num num b = readByte() b readByte() readByte long nextLong() {
			long num = 0;
			int b;
			boolean minus = false;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}

			while (true) {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		} nextLong {
			long num = 0;
			int b;
			boolean minus = false;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}

			while (true) {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		} long num = 0; num 0 int b; b boolean minus = false; minus false while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				; (b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-') (b = readByte()) != -1 (b = readByte()) b readByte() readByte -1 1 !((b >= '0' && b <= '9') || b == '-') ((b >= '0' && b <= '9') || b == '-') (b >= '0' && b <= '9') b >= '0' b '0' b <= '9' b '9' b == '-' b '-' if (b == '-') {
				minus = true;
				b = readByte();
			} b == '-' b '-' {
				minus = true;
				b = readByte();
			} minus = true minus true b = readByte() b readByte() readByte while (true) {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			} true {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			} if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				} b >= '0' && b <= '9' b >= '0' b '0' b <= '9' b '9' {
					num = num * 10 + (b - '0');
				} num = num * 10 + (b - '0') num num * 10 + (b - '0') num * 10 num 10 (b - '0') b '0' {
					return minus ? -num : num;
				} return minus ? -num : num; minus ? -num : num minus -num num num b = readByte() b readByte() readByte public class Main{
	public static InputReader scn = new InputReader();
	public static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) throws Exception {
		//System.out.println("GO");

		int[] div = new int[1001];
		div[1] = 1;
		for (int i = 2; i <= 1e3; i++) {
			if (div[i] == 0) {
				for (int j = i; j <= 1e3; j += i) {
					div[j] = i;
				}
			}
		}

		int n = scn.nextInt();
		for (int i = n; i > 1; i--) {
			if(i == 980) {
				out.println(i);
			}
			HashMap<Integer, Integer> map = new HashMap<>();
			int k = i;
			while (k != 1) {
				if (map.containsKey(div[k])) {
					map.put(div[k], map.get(div[k]) + 1);
				} else {
					map.put(div[k], 1);
				}
				k /= div[k];
			}

			int z = -1;
			for (int x : map.keySet()) {
				if (z == -1) {
					z = map.get(x);
				} else if (map.get(x) != z) {
					z = -2;
				}
			}

			if (z > 1) {
				System.out.println(i);
				return;
			}
		}
		out.println(1);
		out.flush();
	}

	public static class InputReader {
		InputStream is;

		public InputReader() {
			is = System.in;
		}

		byte[] inbuf = new byte[1024];
		public int lenbuf = 0, ptrbuf = 0;

		int readByte() {
			if (lenbuf == -1)
				throw new InputMismatchException();
			if (ptrbuf >= lenbuf) {
				ptrbuf = 0;
				try {
					lenbuf = is.read(inbuf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return -1;
			}
			return inbuf[ptrbuf++];
		}

		boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		int skip() {
			int b;
			while ((b = readByte()) != -1 && isSpaceChar(b))
				;
			return b;
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		char nextChar() {
			return (char) skip();
		}

		String next() {
			int b = skip();
			StringBuilder sb = new StringBuilder();
			while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		char[] next(int n) {
			char[] buf = new char[n];
			int b = skip(), p = 0;
			while (p < n && !(isSpaceChar(b))) {
				buf[p++] = (char) b;
				b = readByte();
			}
			return n == p ? buf : Arrays.copyOf(buf, p);
		}

		char[][] nextMatrix(int n, int m) {
			char[][] map = new char[n][];
			for (int i = 0; i < n; i++)
				map[i] = next(m);
			return map;
		}

		int[] nextArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		int nextInt() {
			int num = 0, b;
			boolean minus = false;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}

			while (true) {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		}

		long nextLong() {
			long num = 0;
			int b;
			boolean minus = false;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}

			while (true) {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		}
	}
} public class Main{
	public static InputReader scn = new InputReader();
	public static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) throws Exception {
		//System.out.println("GO");

		int[] div = new int[1001];
		div[1] = 1;
		for (int i = 2; i <= 1e3; i++) {
			if (div[i] == 0) {
				for (int j = i; j <= 1e3; j += i) {
					div[j] = i;
				}
			}
		}

		int n = scn.nextInt();
		for (int i = n; i > 1; i--) {
			if(i == 980) {
				out.println(i);
			}
			HashMap<Integer, Integer> map = new HashMap<>();
			int k = i;
			while (k != 1) {
				if (map.containsKey(div[k])) {
					map.put(div[k], map.get(div[k]) + 1);
				} else {
					map.put(div[k], 1);
				}
				k /= div[k];
			}

			int z = -1;
			for (int x : map.keySet()) {
				if (z == -1) {
					z = map.get(x);
				} else if (map.get(x) != z) {
					z = -2;
				}
			}

			if (z > 1) {
				System.out.println(i);
				return;
			}
		}
		out.println(1);
		out.flush();
	}

	public static class InputReader {
		InputStream is;

		public InputReader() {
			is = System.in;
		}

		byte[] inbuf = new byte[1024];
		public int lenbuf = 0, ptrbuf = 0;

		int readByte() {
			if (lenbuf == -1)
				throw new InputMismatchException();
			if (ptrbuf >= lenbuf) {
				ptrbuf = 0;
				try {
					lenbuf = is.read(inbuf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return -1;
			}
			return inbuf[ptrbuf++];
		}

		boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		int skip() {
			int b;
			while ((b = readByte()) != -1 && isSpaceChar(b))
				;
			return b;
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		char nextChar() {
			return (char) skip();
		}

		String next() {
			int b = skip();
			StringBuilder sb = new StringBuilder();
			while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		char[] next(int n) {
			char[] buf = new char[n];
			int b = skip(), p = 0;
			while (p < n && !(isSpaceChar(b))) {
				buf[p++] = (char) b;
				b = readByte();
			}
			return n == p ? buf : Arrays.copyOf(buf, p);
		}

		char[][] nextMatrix(int n, int m) {
			char[][] map = new char[n][];
			for (int i = 0; i < n; i++)
				map[i] = next(m);
			return map;
		}

		int[] nextArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		int nextInt() {
			int num = 0, b;
			boolean minus = false;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}

			while (true) {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		}

		long nextLong() {
			long num = 0;
			int b;
			boolean minus = false;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}

			while (true) {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		}
	}
} Main
import java.io.*;
import java.util.*;

public class Main{
	public static InputReader scn = new InputReader();
	public static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) throws Exception {
		//System.out.println("GO");

		int[] div = new int[1001];
		div[1] = 1;
		for (int i = 2; i <= 1e3; i++) {
			if (div[i] == 0) {
				for (int j = i; j <= 1e3; j += i) {
					div[j] = i;
				}
			}
		}

		int n = scn.nextInt();
		for (int i = n; i > 1; i--) {
			if(i == 980) {
				out.println(i);
			}
			HashMap<Integer, Integer> map = new HashMap<>();
			int k = i;
			while (k != 1) {
				if (map.containsKey(div[k])) {
					map.put(div[k], map.get(div[k]) + 1);
				} else {
					map.put(div[k], 1);
				}
				k /= div[k];
			}

			int z = -1;
			for (int x : map.keySet()) {
				if (z == -1) {
					z = map.get(x);
				} else if (map.get(x) != z) {
					z = -2;
				}
			}

			if (z > 1) {
				System.out.println(i);
				return;
			}
		}
		out.println(1);
		out.flush();
	}

	public static class InputReader {
		InputStream is;

		public InputReader() {
			is = System.in;
		}

		byte[] inbuf = new byte[1024];
		public int lenbuf = 0, ptrbuf = 0;

		int readByte() {
			if (lenbuf == -1)
				throw new InputMismatchException();
			if (ptrbuf >= lenbuf) {
				ptrbuf = 0;
				try {
					lenbuf = is.read(inbuf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return -1;
			}
			return inbuf[ptrbuf++];
		}

		boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		int skip() {
			int b;
			while ((b = readByte()) != -1 && isSpaceChar(b))
				;
			return b;
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		char nextChar() {
			return (char) skip();
		}

		String next() {
			int b = skip();
			StringBuilder sb = new StringBuilder();
			while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		char[] next(int n) {
			char[] buf = new char[n];
			int b = skip(), p = 0;
			while (p < n && !(isSpaceChar(b))) {
				buf[p++] = (char) b;
				b = readByte();
			}
			return n == p ? buf : Arrays.copyOf(buf, p);
		}

		char[][] nextMatrix(int n, int m) {
			char[][] map = new char[n][];
			for (int i = 0; i < n; i++)
				map[i] = next(m);
			return map;
		}

		int[] nextArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		int nextInt() {
			int num = 0, b;
			boolean minus = false;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}

			while (true) {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		}

		long nextLong() {
			long num = 0;
			int b;
			boolean minus = false;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}

			while (true) {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		}
	}
}
