unittest
{
	assert( [ "25" ].parse.expand.solve == 17 );
	assert( [ "1" ].parse.expand.solve == 1 );
	assert( [ "100" ].parse.expand.solve == 108 );
	assert( [ "2020" ].parse.expand.solve == 40812 );
	assert( [ "200000" ].parse.expand.solve == 400000008 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	return tuple( n );
}

auto solve( long n )
{
	auto ps = new long[ 10 ][ 10 ];
	foreach( i; 1L .. n + 1 )
	{
		auto t = i % 10;
		if( t == 0 ) continue;
		auto h = i;
		while( 10 <= h ) h /= 10;
		ps[ h ][ t ]++;
	}
	
	auto ans = 0L;
	foreach( i; 1L .. n + 1 )
	{
		auto t = i % 10;
		if( t == 0 ) continue;
		auto h = i;
		while( 10 <= h ) h /= 10;
		ans += ps[ t ][ h ];
	}
	return ans;
}
