
package com.ten;
import java.util.Scanner;
public class Exercise04 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n=sc.nextInt();
int res=0;
int min = (int) (Math.pow(10,n-1));
int max = (int) (Math.pow(10,n)-1);
for(int i=max;i>=min;i--) {
for(int j=max;j>=min;j--) {
int temp=i*j;
if (f(temp) && temp>res) {
res=temp;
}
}
}
System.out.println(res);
}
public static boolean f(int num){
String str = num+"";
int length = str.length();
int num2=0;
for(int i=0;i<length/2;i++) {
num2=num%10+num2*10;
num=num/10;
}
if(length%2!=0) {
num=num/10;
}
return num==num2;
}
}