#include<iostream>
#include<string>
#include<algorithm>

using namespace std;
#define LL long long

int N,ans;
int cnt[10][10]={};

int main(){
	cin>>N;
	for(int i=1;i<=N;i++){
		if(i%10==0)continue;
		int tmp;
		for(tmp=1;tmp<=i;tmp*=10);
		tmp/=10;
		cnt[i/tmp][i%10]++;
		if(i/tmp==i%10)
			ans+=cnt[i/tmp][i%10]*2-1;
		else ans+=cnt[i%10][i/tmp]*2;
	}
	cout<<ans<<endl;
	return 0;
}

