#include<bits/stdc++.h>

using namespace std;

#define int long long

vector<vector<int>>v(10,vector<int>(10,0));

int32_t main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        int val=i;
        while(val>=10)val/=10;
        v[val][i%10]+=1;
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        int val=i;
        while(val>=10)val/=10;
        ans+=v[i%10][val];
    }
    cout<<ans<<endl;
}
