#include <iostream>
/* A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 99.
Find the largest palindrome made from the product of two 3-digit numbers. */
usingnamespace std;
int main()
{
int v = 0;
int a, b, c, d, e, f;
int x = 999;
int y = 999;
int z = a * x;
while (y > 0){
if ((100 < z) && (z < 1000)){
a = z % 10;
b = ((z % 100) - a) / 10;
c = ((z % 1000) - a -(10 * b)) / 100;
if ((a == c) && (z > v)){
v = z;
}
}
if ((1000 < z) && (z < 10000)){
a = z % 10;
b = ((z % 100) - a) / 10;
c = ((z % 1000) - a -(10 * b)) / 100;
d = ((z % 10000) - a - (10 * b) - (100 * c)) / 1000;
if ((a == d) && (c == d) && (z > v)){
v = z;
}
}
if ((10000 < z) && (z < 100000)){
a = z % 10;
b = ((z % 100) - a) / 10;
c = ((z % 1000) - a -(10 * b)) / 100;
d = ((z % 10000) - a - (10 * b) - (100 * c)) / 1000;
e = ((z % 100000) - a - (10 * b) - (100 * c) - (1000 * d)) / 10000;
if ((a == e) && (b == d) && (z > v)){
v = z;
}
}
if ((100000 < z) && (z < 1000000)) {
a = z % 10;
b = ((z % 100) - a) / 10;
c = ((z % 1000) - a -(10 * b)) / 100;
d = ((z % 10000) - a - (10 * b) - (100 * c)) / 1000;
e = ((z % 100000) - a - (10 * b) - (100 * c) - (1000 * d)) / 10000;
f = ((z % 1000000) - a - (10 * b) - (100 * c) - (1000 * d) - (10000 * e)) / 100000;
if ((a == f) && (b == e) && (c == d)&& (z > v)){
v = z;
}
}
x --;
if (x == 1){
y --;
x = 999;
}
z = y * x;
}
cout << v << endl;
return 0;
}