#python3

from collections import defaultdict

from collections import namedtuple



P = namedtuple('P', ['front', 'end'])



def f(x):

    return P(str(x)[0], str(x)[-1]) 



def main():



    n = int(eval(input()))

    freq = defaultdict(int)



    for i in range(1, n+1):

        p = f(i)

        freq[p]+=1





    ans = 0

    for i in range(1, n + 1):

        p = f(i)

        q = (p.end, p.front)

        ans += freq[q]



    print(ans)



main()
import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines



from collections import defaultdict



def f(x):

    return (int(str(x)[0]), int(str(x)[-1])) 

def main():

    N = int(readline())

    df = defaultdict(int)

    for i in range(1, N+1):

        df[f(i)] += 1

    ans = 0

    for i in range(1, 10):

        for j in range(1, 10):

            ans +=  df[(i, j)]*df[(j, i)]

    print(ans)

if __name__ == '__main__':

    main()

# python3
from collections import defaultdict
from collections import namedtuple

P = namedtuple("P", ["front", "end"])


def f(x):
    return P(str(x)[0], str(x)[-1])


def main():
    n = int(eval(input()))
    freq = defaultdict(int)
    for i in range(1, n + 1):
        p = f(i)
        freq[p] += 1
    ans = 0
    for i in range(1, n + 1):
        p = f(i)
        q = (p.end, p.front)
        ans += freq[q]
    print(ans)


main()

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from collections import defaultdict


def f(x):
    return (int(str(x)[0]), int(str(x)[-1]))


def main():
    N = int(readline())
    df = defaultdict(int)
    for i in range(1, N + 1):
        df[f(i)] += 1
    ans = 0
    for i in range(1, 10):
        for j in range(1, 10):
            ans += df[(i, j)] * df[(j, i)]
    print(ans)


if __name__ == "__main__":
    main()

-# python3 +import sys + +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines -from collections import namedtuple - -P = namedtuple("P", ["front", "end"]) -    return P(str(x)[0], str(x)[-1]) +    return (int(str(x)[0]), int(str(x)[-1])) -    n = int(eval(input())) -    freq = defaultdict(int) -    for i in range(1, n + 1): -        p = f(i) -        freq[p] += 1 +    N = int(readline()) +    df = defaultdict(int) +    for i in range(1, N + 1): +        df[f(i)] += 1 -    for i in range(1, n + 1): -        p = f(i) -        q = (p.end, p.front) -        ans += freq[q] +    for i in range(1, 10): +        for j in range(1, 10): +            ans += df[(i, j)] * df[(j, i)] -main() +if __name__ == "__main__": +    main()