// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



using vi = vector<int>;

using vll = vector<long long>;



constexpr long long mod = 1000000007;



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



int main() {

    ios::sync_with_stdio(false);

    cin.tie(0);



    long long n;

    cin >> n;



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



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

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

            if (i == j && i <= n) {

                v[i][j]++;

            }



            string t = to_string(i) + to_string(j);



            if (stoll(t) <= n) {

                v[i][j]++;

            }



            for (int k = 0; k < 10; k++) {

                string temp = to_string(i) + to_string(k) + to_string(j);

                if (stoll(temp) <= n) {

                    v[i][j]++;

                } else {

                    break;

                }

            }

            for (int k = 0; k < 100; k++) {

                ostringstream ss;

                ss << setw(2) << setfill('0') << k;



                string temp = to_string(i) + ss.str() + to_string(j);

                if (stoll(temp) <= n) {

                    v[i][j]++;

                } else {

                    break;

                }

            }



            for (int k = 0; k < 1000; k++) {

                ostringstream ss;

                ss << setw(3) << setfill('0') << k;



                string temp = to_string(i) + ss.str() + to_string(j);

                if (stoll(temp) <= n) {

                    v[i][j]++;

                } else {

                    break;

                }

            }

            for (int k = 0; k < 10000; k++) {

                ostringstream ss;

                ss << setw(4) << setfill('0') << k;



                string temp = to_string(i) + ss.str() + to_string(j);

                if (stoll(temp) <= n) {

                    v[i][j]++;

                } else {

                    break;

                }

            }

        }

    }



    long long cnt = 0;

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

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

            cnt += v[i][j] * v[j][i];

        }

    }



    cout << cnt << endl;

}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;



using vi = vector<int>;

using vll = vector<long long>;



constexpr long long mod = 1000000007;



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



int main() {

    ios::sync_with_stdio(false);

    cin.tie(0);



    long long n;

    cin >> n;



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



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

        if (i <= n) {

            v[i][i]++;

        }

    }



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

        int b = i % 10;

        string t = to_string(i);

        int a = t[0] - '0';



        if (a != 0 && b != 0) {

            v[a][b]++;

        }

    }



    long long cnt = 0;

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

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

            cnt += v[i][j] * v[j][i];

        }

    }



    cout << cnt << 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;

}