// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 1.4449341801956983x):
#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;

}