import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional, std.meta;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.typecons;

void main()
{
    int n;
    readf("%s", &n);
    readln;
    
    int getFst(int x, int dig) {
        int dv = 10 ^^ (dig - 1);
        x /= dv;
        
        return x % 10;
    }
    
    int getLst(int x) {
        return x % 10;
    }
    
    immutable int len = n.to!string.length.to!int;
    immutable int nfst = getFst(n, len);
    
    int getNr(int fst, int lst, int dig) {
        if (dig == 1) {
            return fst == lst ? 1 : 0;
        }
        
        if (dig > len
            || (dig == len && fst > nfst)) {
            return 0;
        }
        
        if (dig < len || fst < nfst) {
            return 10 ^^ (dig-2);
        }
        
        int tot = 0;
        foreach (ins; 0 .. 10 ^^ (dig - 2)) {
            tot += fst * (10 ^^ (dig-1)) + ins * 10 + lst <= n ? 1 : 0;
        }
        
        return tot;
    }
    
    
    long ans = 0;
    foreach (x; 1 .. 10) {
        foreach (y; 1 .. 10) {
            foreach (d1; 1 .. len + 1) {
                foreach (d2; 1 .. len + 1) {
                    if (d1 == 1 && x != y) { continue; }
                    if (d2 == 1 && x != y) { continue; }
                    
                    ans += getNr(x, y, d1).to!long * getNr(y, x, d2);
                    
                    debug { writeln(x, ' ', y, ' ', d1, ' ', d2, ' ', getNr(x, y, d1), ' ', getNr(y, x, d2)); }
                }
            }
        }
    }
    
    ans.writeln;
}