#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;

/*typedefs*/
typedef vector<int> vi;
typedef map<string,int> msi;
typedef complex<double> point;
typedef  long long ll;


#define all(v)			((v).begin()), ((v).end())
#define SIZE(v)			((int)((v).size()))
#define LOG(x)			log((double)x)
#define TOLOWER(x)          transform(all(x),x.begin(),::tolower)
#define TOUPPER(x)          transform(all(x),x.begin(),::toupper)
#define ROUND(x,m)			(round((double)x/m)*m)
#define DIGITS(x)			(floor(log10((double)x))+1)
#define READSTR(x)			getline(cin,x)
#define sort_g(a,b)              sort(a, b, greater<int>());
#define X real()
#define Y imag()
#define angle(a)                (atan2((a).imag(), (a).real()))
#define vec(a,b)                ((b)-(a))
#define same(p1,p2)             (dp(vec(p1,p2),vec(p1,p2)) < EPS)
#define dp(a,b)                 ( (conj(a)*(b)).real() )	// a*b cos(T), if zero -> prep
#define cp(a,b)                 ( (conj(a)*(b)).imag() )	// a*b sin(T), if zero -> parllel
#define length(a)               (hypot((a).imag(), (a).real()))
#define normalize(a)            (a)/length(a)
#define rotateO(p,ang)          ((p)*exp(point(0,ang)))
#define rotateA(p,ang,about)  (rotateO(vec(about,p),ang)+about)
#define reflectO(v,m)  (conj((v)/(m))*(m))
#define IOS() ios_base::sync_with_stdio(0);cin.tie(NULL);
#define REP(i, n) for (int i = 0; i < n; i++)
#define FILE_INPUT() 	freopen( "input.txt", "r", stdin)
#define FILE_OUTPUT()   freopen( "output.txt", "w", stdout)

bool myCmp(pair<int,int> &p1 , pair<int,int>&p2)
{
    return p1.first > p2.first;
}


unsigned long long
choose(unsigned long long n, unsigned long long k) {
    if (k > n) {
        return 0;
    }
    unsigned long long r = 1;
    for (unsigned long long d = 1; d <= k; ++d) {
        r *= n--;
        r /= d;
    }
    return r;
}
int toInt(string str)
{
    int num;
    std::istringstream iss(str); //put string in input stream
    iss >> num; return num; //read from stream as integer
}
ll  OO = 10e6;

ll p10(ll x)
{
    ll s = 1;
    for(int i = 0 ; i < x;i++)
    {
        s=s*10;
    }
    return s;
}
int main() {
    IOS();

    ll cnt=0;
    string n_s;
    cin>>n_s;
    char st = n_s.front();
    char ed = n_s.back();

    if(n_s.size() == 1)
    {
        cout<<n_s<<endl;
        return 0;
    }
    cnt = 9;

    ll span =1;
    if(n_s.size() >=3)
        span = 1+toInt(n_s.substr(1,n_s.size()-2));

    ll range = 0, range1 = 0;

    // cout<<"span "<<span<<endl;
    for(char i = '1' ; i <='9' ; ++i)
    {
        for(char j = '1' ; j <='9' ;++j)
        {
            for(ll lolo = 2 ; lolo <= n_s.size() ; ++lolo)
            {
                for(ll soso = 2 ; soso <= n_s.size() ; ++soso)
                {
                    //  cout<<" i = "<<i<<" j "<<j<<" lolo = "<<lolo<<" soso = "<<soso<<endl;
                    if( ( (i>st) && (lolo == n_s.size()))|| ( (j>st) && (soso == n_s.size()))) continue;

                    range1 = p10(soso-2);
                    range = p10(lolo-2);
                    if(soso == n_s.size()&& (st == j))
                    {
                        //how many 2xx1 that doesn't exceed 2020
                        //put zero if possible
                        if(i <= ed)
                            range1 = span;
                        else
                            range1 = span-1;

                    }
                    if( (lolo == n_s.size()) && (st == i))
                    {
                        if(j <= ed)
                            range = span;
                        else
                            range = span-1;
                    }
                    cnt += (range1*range);
                    // cout<<"cnt = "<<cnt<<endl;
                }
                //1 againest all
                if( i == j)
                {
                    if(lolo == n_s.size() && (i>st))
                    {
                    }
                    else
                    {
                        cnt+= 2*range;
                    }

                }
            }
        }
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256