using System;
class ProgramD
    {
        static void Main(string[] args)
        {
            
            //入力
            int n = int.Parse(Console.ReadLine());
            

            int count = 1;
            
            for(int i = 2;i <= n;i++)
            {
                if(i % 10 == 0)
                    continue;

                if(i < 10)
                {
                    count++;
                }
                else if(11 <= i && i <= 99)
                {
                    int a1 = i /10;
                    int a2 = i - a1*10;

                    if(a1 == a2)
                        count += 3;
                    else if(a1 > a2)
                        count += 2;
                }
                else if(101 <= i && i <= 999)
                {
                    int b1 = i / 100;
                    int b2 = (i - b1*100)/10;
                    int b3 = i - b2*10 - b1*100;

                    if(b1 == b3)
                        count += 5 + b2*2;
                    else if(b1 > b3)
                        count += 22;
                    else if(b1 < b3)
                        count += 2;
                    
                }
                else if(1001 <= i && i <= 9999)
                {
                    int c1 = i / 1000;
                    int c2 = (i - c1*1000)/100;
                    int c3 = (i - c2*100 - c1*1000)/10;
                    int c4 = i - c3*10 - c2*100 - c1*1000;

                    if(c1 == c4)
                        count += 25 + c2*20 + c3*2;
                    else if(c1 > c4)
                        count += 222;
                    else if(c1 < c4)
                        count += 22;
                    
                }
                else if(10001 <= i && i <= 99999)
                {
                    int d1 = i / 10000;
                    int d2 = (i - d1*10000)/1000;
                    int d3 = (i - d2*1000 - d1*10000)/100;
                    int d4 = (i - d3*100 - d2*1000 - d1*10000)/10;
                    int d5 = i - d4*10 - d3*100 - d2*1000 - d1*10000;

                    if(d1 == d5)
                        count += 225 + d2*200 + d3*20 + d4*2;
                    else if(d1 > d5)
                        count += 2222;
                    else if(d1 < d5)
                        count += 222;
                    
                }
                else if(100001 <= i)
                {
                    int e1 = i / 100000;
                    int e2 = (i - e1*100000)/10000;
                    int e3 = (i - e2*10000 - e1*100000)/1000;
                    int e4 = (i - e3*1000 - e2*10000 - e1*100000)/100;
                    int e5 = (i - e4*100 - e3*1000 - e2*10000 - e1*100000)/10;
                    int e6 = i - e5*10 - e4*100 - e3*1000 - e2*10000 - e1*100000;

                    if(e1 == e6)
                        count += 2225 + e2*2000 + e3*200 + e4*20 + e5*2;
                    else if(e1 > e6)
                        count += 22222;
                    else if(e1 < e6)
                        count += 2222;
                    
                }
                
            }

            Console.WriteLine(count);
          
        } 
    }  

Measured memory_bytes: 11092