#include <iostream>
#include <string>
#include <algorithm>
bool P(int value)
{
std::string left = std::to_string(value);
std::reverse(left.begin(), left.end());
std::string right = std::to_string(value);;
return left == right;
}
int main()
{
int n;
std::cin >> n;
int count = 0;
for (int i = 1; i <= n; ++i)
{
if (P(i))
{
count++;
}
}
std::cout << "Count palindrome: " << count << std::endl;
return 0;
}
A,Sc,Sn:integer;
Begin
Sc:=0;
Sn:=0;
Write('Введите четырёхзначное число: ');ReadLn(A);
//Если чётных(0,2,4,6,8) и нечётных(1,3,5,7,9) чисел:
if (A div 1000) mod 2 = 0 then Sc:=Sc+A div 1000
else Sn:=Sn+A div 1000;
if ((A div 100) mod 10) mod 2 = 0 then Sc:=Sc+(A div 100) mod 10
else Sn:=Sn+(A div 100) mod 10;
if ((A div 10) mod 10) mod 2 = 0 then Sc:=Sc+(A div 10) mod 10
else Sn:=Sn+(A div 10) mod 10;
if (A mod 10) mod 2 = 0 then Sc:=Sc+(A mod 10)
else Sn:=Sn+(A mod 10);
if Sc<Sn then WriteLn(Sn,' ',Sc)
else WriteLn(Sc,' ',Sn);
//Если чисел, стоящих на чётных и нечётных позициях:
Sc:=(A mod 10)+(A div 100) mod 10;
Sn:=(A div 10) mod 10 + A div 1000;
if Sc<Sn then WriteLn(Sn,' ',Sc)
else WriteLn(Sc,' ',Sn);
End.