#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;
}