import std.stdio, std.string, std.conv;
import std.typecons;
import std.algorithm, std.array, std.range, std.container;
import std.math;

void main() {
    auto N = readln.split.to!(uint[])[0];
    //writeln(countB(12, 25));
    writeln(iota(1,N+1).map!( x => countB(x,N) ).sum());
}

uint countB(uint A, uint N) {
    auto hA = head(A), tA = tail(A);
    if (tA == 0) return 0;
    
    string h = to!string(hA), t = to!string(tA);
    uint result;
    
    if (hA == tA) result++;
    auto th = t~h;
    if ( parse!uint(th) <= N ) result++;
    
    auto d = digit(N);
    auto hN = head(N), tN = tail(N);
    if (digit(N) <= 2) return result;
    uint center = ( N - hN*10^^(d-1) - tN ) / 10;
    
    if      ( hN >  tA )         result += 10^^(d-2);
    else if ( hN == tA )
             if ( tN >= hA )     result += center+1;
             else                result += center;
    else                         {}
    
    result += iota(1,d-2).map!(x => 10^^x).sum();
    
    return result;
}

uint countZeros(string a, string b, uint N) {
    uint result;
    
    string ab = a ~ b;
    if (parse!uint(ab) <= N) result++;
    else return 0;
    
    for (uint i=1; ; i++) {
        string a_zeros_b = a ~ "0".repeat(i).reduce!"a~b" ~ b;
        if ( parse!uint(a_zeros_b) <= N ) result++;
        else break;
    }
    return result;
}

uint tail(uint n) {
    return n%10;
}

uint head(uint n) {
    if (n<10) return n;
    else return head(n/10);
}

uint digit(uint n) {
    if (n<10) return 1;
    else return digit(n/10) + 1;
}