using System;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Text;
 
public class Program
{
    public void Proc() {
        Reader.IsDebug = false;
        decimal inpt = decimal.Parse(Reader.ReadLine());
        this.max = inpt;

        long ans = 0;
        for(int i=0; i<=9; i++) {
            long ret = GetNum(i.ToString());
            if(ret >= 0) {
                ans+=ret;
            }
            ret = GetNum(i.ToString()+i);
            if(ret >= 0) {
                ans+=ret;
            }
        }
        Console.WriteLine(ans);
    }

    private Dictionary<string, bool> flag = new Dictionary<string, bool>();

    private Dictionary<decimal, bool> flagNum = new Dictionary<decimal, bool>();
    private long GetNum(string tmp) {
        if(flag.ContainsKey(tmp)) {
            return 0;
        }
        flag[tmp] = true;
        decimal num = decimal.Parse(tmp);

        if(num*baseNum > max) {
            return -1;
        }
        if(tmp.Length >= 10) {
            return -1;
        }

        long ans = 0;
        if(!flagNum.ContainsKey(num)) {
            if(num > 0 && num.ToString().Length == tmp.Length) {
                ans++;
            }
            flagNum[num] = true;
        }
        for(int i=0; i<=9; i++) {
            long ret = GetNum(i + tmp + i);
            if(ret >= 0) {
                ans+=ret;
            }  else {
                break;
            }
        }
        return ans;
    }

    private decimal max = 0;

    private decimal baseNum = 1000000000 + 1;





    public class Reader {
        public static bool IsDebug = true;
        private static System.IO.StringReader SReader;
        private static string InitText = @"


40000000000


";
        public static string ReadLine() {
            if(IsDebug) {
                if(SReader == null) {
                    SReader = new System.IO.StringReader(InitText.Trim());
                }
                return SReader.ReadLine();
            } else {
                return Console.ReadLine();
            }
        }
    }
    public static void Main(string[] args)
    {
        Program prg = new Program();
        prg.Proc();
    }
}