#include <bits/stdc++.h>
#define int long long
using namespace std;
int n;
int a[20][20];
int ans;
signed main()
{
scanf("%lld",&n);
for(int i = 1;i <= n;i ++)
{
int p,q;
p = q = i;
while(p > 0)
{
q = p;
p /= 10;
}
a[q][i % 10] ++;
}
for(int i = 1;i <= 9;i ++)
{
ans += (a[i][i] - 1) * a[i][i] / 2;
for(int j = i + 1;j <= 9;j ++)
{
ans += a[i][j] * a[j][i];
}
}
printf("%lld",ans);
return 0;
}