// Original C++ solution (slower):
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>

using namespace std;

struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;

#define max3(a,b,c) max(a,max(b,c))

#define min3(a,b,c) min(a,min(b,c))

#define MOD 1000000007

#define INF (1<<30)

#define LINF (lint)(1LL<<56)

#define endl "\n"

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)

#define Flag(x) (1<<(x))

#define Flagcount(x) __builtin_popcount(x)

#define pint pair<int,int>

#define pdouble pair<double,double>

#define plint pair<lint,lint>

typedef long long lint;

int dx[8]={1,1,0,-1,-1,-1,0,1};

int dy[8]={0,1,1,1,0,-1,-1,-1};



lint calc(lint x){

    lint keta=(lint)(1+floor(log10(x)));

    lint top=x/(lint)(pow(10,keta-1));

    lint res=0;

    lint ketac=2;

    lint botom=x%10;

    if(top==botom){

        res+=3;

        while(ketac<keta) res+=(lint)pow(10,ketac-2)*2,ketac++;

        lint rem=(x-top*(lint)pow(10,keta-1)-botom)/5;

        if(keta>=3) res+=rem;

    }

    if(top>botom) while(ketac<=keta) res+=(lint)pow(10,ketac-2)*2,ketac++;

    if(top<botom) while(ketac<keta) res+=(lint)pow(10,ketac-2)*2,ketac++;

    return res;

}



int main(void){

    lint N;

    cin >> N;

    lint dp[220000]={};

    for(int i=1;i<=9;i++) dp[i]=i;

    for(int i=10;i<=N;i++){

        if(i%10==0) dp[i]=dp[i-1];

        else dp[i]=dp[i-1]+calc(i);

    }

    cout << dp[N] << endl;

}

// Optimized solution to the same problem (faster):
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>

using namespace std;

struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;

#define max3(a,b,c) max(a,max(b,c))

#define min3(a,b,c) min(a,min(b,c))

#define MOD 1000000007

#define INF (1<<30)

#define LINF (lint)(1LL<<56)

#define endl "\n"

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)

#define Flag(x) (1<<(x))

#define Flagcount(x) __builtin_popcount(x)

#define pint pair<int,int>

#define pdouble pair<double,double>

#define plint pair<lint,lint>

typedef long long lint;

int dx[8]={1,1,0,-1,-1,-1,0,1};

int dy[8]={0,1,1,1,0,-1,-1,-1};



pint pick(int x){

    pint res;

    res.second=x%10;

    while(x){

        res.first=x;

        x/=10;

    }

    return res;

}



int main(void){

    int N;

    cin >> N;

    lint sum[10][10]={};

    lint ans=0;

    for(int i=1;i<=N;i++){

        pint p=pick(i);

        sum[p.first][p.second]++;

    }

    for(int i=1;i<=9;i++) for(int j=1;j<=9;j++){

        ans+=sum[i][j]*sum[j][i];

    }

    cout << ans << endl;

}

// Fastest known solution for this problem:
/*

confirm 0LL and 1LL

confirm cornercases such as 0

confirm times of cin < 10^6

*/

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

using ld = long double;

using P = pair<ll, ll>;

using Pld = pair<ld, ld>;

using Vec = vector<ll>;

using VecP = vector<P>;

using VecB = vector<bool>;

using VecC = vector<char>;

using VecD = vector<ld>;

using VecS = vector<string>;

using VecVec = vector<Vec>;

using Tree = vector<VecP>;

template <typename T>

using Vec1 = vector<T>;

template <typename T>

using Vec2 = vector<Vec1<T> >;

#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))

#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))

#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))

#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))

#define rep(i, n) REP(i, 0, n)

#define repn(i, n) REPN(i, 1, n)

#define repr(i, n) REPR(i, n, 0)

#define repnr(i, n) REPNR(i, n, 1)

#define all(s) (s).begin(), (s).end()

#define pb push_back

#define mp make_pair

#define fs first

#define sc second

template <typename T>

bool chmax(T &a, const T& b){if(a < b){a = b; return true;} return false;}

template <typename T>

bool chmin(T &a, const T& b){if(a > b){a = b; return true;} return false;}

template <typename T>

void co(const T n){cout << n << endl;}

template <typename T>

void cosp(const T n){cout << n << ' ';}

void coVec(const Vec &v){for(ll i : v) cosp(i); cout << endl;}

void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}

void setp(const ll n){cout << fixed << setprecision(n);}

const ll INF = 1e9+1;

const ll LINF = 1e18+1;

const ll MOD = 1e9+7;

//const ll MOD = 998244353;

const ld PI = acos(-1);

const ld EPS = 1e-11;



int main(void){

	ll n;

	cin >> n;



	VecVec c(10, Vec(10));



	repn(i, n){

		string s = to_string(i);

		ll a = s[0]-'0', b = s[s.size()-1]-'0';

		c[a][b]++;

	}



	ll ans = 0;

	rep(i, 10){

		rep(j, 10) ans += c[i][j]*c[j][i];

	}

	co(ans);



	return 0;

}