#include <bits/stdc++.h>

using namespace std;

int n, cnt[10][10];

int main() {
	scanf("%d", &n);
	
	for (int i = 1; i <= n; i++) {
		int ed = i % 10;
		int st = 0;
		int tmp = i;
		while (tmp) {
			st = tmp % 10;
			tmp /= 10;
		}
		cnt[st][ed]++;
	}
	
	long long res = 0;
	
	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			res += cnt[i][j] * cnt[j][i];
		}
	}
	
	printf("%lld\n", res);
}
