/***************************************************
 * Problem Name : D.cpp
 * Problem Link : https://atcoder.jp/contests/abc152/tasks/abc152_d
 * OJ           : atCoder
 * Verdict      : 
 * Date         : 2020-01-19
 * Problem Type : ABC - D
 * Author Name  : Saikat Sharma
 * University   : CSE, MBSTU
 ***************************************************/
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <cstdlib>
#include <deque>
#include <stack>
#include <bitset>
#include <cassert>
#include <map>
#include <set>
#include <cassert>
#include <iomanip>
#include <random>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;

#define __FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define __FileRead freopen ("input.txt", "r", stdin)
#define __FileWrite freopen ("output.txt", "w", stdout)
#define SET(a,v) memset(a,v,sizeof(a))
#define SZ(v) (int)v.size()
#define pii pair<int,int>
#define pil pair <int, ll>
#define pli pair <ll, int>
#define pll pair <ll, ll>
#define debug cout <<"######\n"
#define debug1(x) cout <<"### " << x << " ###\n"
#define debug2(x,y) cout <<"# " << x <<" : "<< y <<" #\n"
#define nl cout << "\n";
#define sp cout << " ";
#define sl(n) scanf("%lld", &n)
#define sf(n) scanf("%lf", &n)
#define si(n) scanf("%d", &n)
#define ss(n) scanf("%s", n)
#define pf(n) scanf("%d", n)
#define pfl(n) scanf("%lld", n)
#define all(v) v.begin(), v.end()
#define rall(v) v.begin(), v.end()
#define srt(v) sort(v.begin(), v.end())
#define r_srt(v) sort(v.rbegin(), v.rend())
#define rev(v) reverse(v.begin(), v.end())
#define Sqr(x) ((x)*(x))
#define Mod(x, m) ((((x) % (m)) + (m)) % (m))
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define pb push_back
#define mk make_pair
#define MAX 200005
#define INF 1000000009
#define MOD 1000000007

template<class T>
using min_heap = priority_queue<T, std::vector<T>, std::greater<T>>;
template<typename T>
using ordered_set  = tree<T, null_type, less<T>, rb_tree_tag,
      tree_order_statistics_node_update>;

template <typename T> string toString ( T Number ) {
    stringstream ss;
    ss << Number;
    return ss.str();
}
template<typename T> int toInt (T str) {
    stringstream ss;
    ss << str;
    int num;
    ss >> num;
    return num;
}
ll lcm (ll a, ll b) {
    return a * b / __gcd (a, b);
}
/************************************ Code Start Here ******************************************************/
ll cum[MAX];
bool isV (string a, string b) {
    int n1 = (int) a.size();
    int n2 = (int) b.size();

    if (a[0] == b[n2 - 1] && a[n1 - 1] == b[0]) {
        return true;

    } else {
        return false;
    }
}

int fun (int n) {
    int cnt = 0;

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            string a = toString (i);
            string b = toString (j);

            if (isV (a, b) ) cnt++;
        }
    }

    return cnt;
}

void pre() {
    cum[0] = 0;

    for (int i = 1; i <= 100; i++) {
        cum[i] = fun (i);
    }

    ll x = 5;
    ll sum = cum[100] + 5;

    for (int i = 101; i < MAX; i++) {
        cum[i] = sum;

        if ( (i + 1) % 10 != 0 && i % 10 != 0) {
            sum += 2LL;

        } else if (i % 10 == 0) {
            x += 2LL;
            sum += x;
        }
        //~ if(i%100 == 0)sum-=2LL;
    }
    //~ ll y = 3LL;
    //~ for(int i = 201; i<=MAX; i+=10){
		//~ cum[i]-=y;
		//~ y+=2LL;
	//~ }
}


int main () {
    //~ __FastIO;
    //~ cout << setprecision (10);
    //~ cout << fixed;
    //~ pre();
    int n;
    cin >> n;
    //~ cout << cum[n] << "\n";
    //~ }
    map<int,map<int,int>>mp;
    for(int k = 1; k<=n; k++){
		string str = toString(k);
		int i = str[0]-'0';
		int j = str[(int)str.size()-1]-'0';
		mp[i][j]++;
	}
    ll sum = 0;
    for(int i = 0; i<=9; i++){
		for(int j = 0; j<=9; j++){
			sum+= (mp[i][j]*mp[j][i]);
		}
	}
	cout << sum << "\n"; 
    //~ for (int i = 200; i <= n; i++) {
		//~ cout << i << " : " << fun(i) << " \n";
		//~ cout << i << " : " << cum[i] << " -\n";
		//~ if(fun(i) != cum[i]){
			//~ cout << i << "---\n";
		//~ }
    //~ }
    //~ cout << "end\n";
    return 0;
}


Measured memory_bytes: 256