Not long ago Billy came across such a problem, where there were given three natural numbers A, B and C from the range [1, N], and it was asked to check whether the equation AB = C is correct. Recently Billy studied the concept of a digital root of a number. We should remind you that a digital root d(x) of the number x is the sum s(x) of all the digits of this number, if s(x) ≤ 9, otherwise it is d(s(x)). For example, a digital root of the number 6543 is calculated as follows: d(6543) = d(6 + 5 + 4 + 3) = d(18) = 9. Billy has counted that the digital root of a product of numbers is equal to the digital root of the product of the factors' digital roots, i.e. d(xy) = d(d(x)d(y)). And the following solution to the problem came to his mind: to calculate the digital roots and check if this condition is met. However, Billy has doubts that this condition is sufficient. That's why he asks you to find out the amount of test examples for the given problem such that the algorithm proposed by Billy makes mistakes.

The first line contains the only number N (1 ≤ N ≤ 106).

Output one number — the amount of required A, B and C from the range [1, N].

NoteFor the first sample the required triples are (3, 4, 3) and (4, 3, 3).

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Numerics;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {

        private static int CalcD(int num)
        {
            var s = num.ToString().Sum(ch => (int)char.GetNumericValue(ch));
            if (s <= 9)
            {
                return s;
            }
            else
            {
                return CalcD(s);
            }
        }

        static void Main(string[] args)
        {
            var nInt = Convert.ToInt32(Console.ReadLine());

            var n = new BigInteger(nInt);
            BigInteger errors = 0;

            BigInteger c = 0;

            for (int i = 1; i <= n; i++)
            {
                if (n < i * i)
                {
                    break;
                }
                else
                {
                    for (int j = i; n >= j * i; j++)
                    {
                        if (i == j)
                        {
                            c++;
                        }
                        else
                        {
                            c += 2;
                        }
                    }
                }
            }

            var max = n > 9 ? 9 : n;
            for (int A = 1; A <= max; A++)
            {
                for (int B = 1; B <= max; B++)
                {
                    for (int C = 1; C <= max; C++)
                    {
                        if (C == CalcD(A * B))
                        {
                            BigInteger tmp = ((((n - C)/9) + 1)*(((n - A)/9) + 1)*(((n - B)/9) + 1));
                            errors += tmp;
                        }

                    }
                }
            }

            Console.WriteLine(errors - c);
            //Console.ReadKey();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;

// (づ°ω°)づﾐe★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver
{
    public void Solve()
    {
        int n = ReadInt();

        var a = new int[10];
        var dp = new int[Math.Max(100, n + 1)];
        for (int i = 1; i <= Math.Max(99, n); i++)
        {
            if (i > 9)
            {
                int x = i;
                int s = 0;
                while (x > 0)
                {
                    s += x % 10;
                    x /= 10;
                }
                dp[i] = dp[s];
            }
            else
                dp[i] = i;

            if (i <= n)
                a[dp[i]]++;
        }

        long ans = 0;
        for (int i = 1; i < 10; i++)
            for (int j = 1; j < 10; j++)
                ans += 1L * a[i] * a[j] * a[dp[i * j]];

        for (int i = 1; i <= n; i++)
            ans -= n / i;

        Write(ans);
    }

    #region Main

    protected static TextReader reader;
    protected static TextWriter writer;
    static void Main()
    {
#if DEBUG
        reader = new StreamReader("..\\..\\input.txt");
        //reader = new StreamReader(Console.OpenStandardInput());
        writer = Console.Out;
        //writer = new StreamWriter("..\\..\\output.txt");
#else
        reader = new StreamReader(Console.OpenStandardInput());
        writer = new StreamWriter(Console.OpenStandardOutput());
        //reader = new StreamReader("input.txt");
        //writer = new StreamWriter("output.txt");
#endif
        try
        {
            //var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);
            //thread.Start();
            //thread.Join();
            new Solver().Solve();
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex);
#if DEBUG
#else
            throw;
#endif
        }
        reader.Close();
        writer.Close();
    }

    #endregion

    #region Read / Write
    private static Queue<string> currentLineTokens = new Queue<string>();
    private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\t', }, StringSplitOptions.RemoveEmptyEntries); }
    public static string ReadToken() { while (currentLineTokens.Count == 0)currentLineTokens = new Queue<string>(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }
    public static int ReadInt() { return int.Parse(ReadToken()); }
    public static long ReadLong() { return long.Parse(ReadToken()); }
    public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }
    public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }
    public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }
    public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }
    public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray(); return matrix; }
    public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)
    {
        int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];
        for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i]; } return ret;
    }
    public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim(); return lines; }
    public static void WriteArray<T>(IEnumerable<T> array) { writer.WriteLine(string.Join(" ", array)); }
    public static void Write(params object[] array) { WriteArray(array); }
    public static void WriteLines<T>(IEnumerable<T> array) { foreach (var a in array)writer.WriteLine(a); }
    private class SDictionary<TKey, TValue> : Dictionary<TKey, TValue>
    {
        public new TValue this[TKey key]
        {
            get { return ContainsKey(key) ? base[key] : default(TValue); }
            set { base[key] = value; }
        }
    }
    private static T[] Init<T>(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; }
    #endregion
}

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;

class Program
{
    public static int[] Read(string str)
    {
        string[] tokens = str.Trim().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
        int[] ret = new int[tokens.Length];
        for (int i = 0; i < ret.Length; i++)
        {
            ret[i] = int.Parse(tokens[i]);
        }

        return ret;
    }

    public static double[] ReadDouble(string str)
    {
        string[] tokens = str.Trim().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
        double[] ret = new double[tokens.Length];
        for (int i = 0; i < ret.Length; i++)
        {
            ret[i] = double.Parse(tokens[i], CultureInfo.InvariantCulture);
        }

        return ret;
    }

    static string Reverse(string s)
    {
        char[] a = s.ToCharArray();
        Array.Reverse(a);
        return new string(a);
    }

    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine().Trim());

        int[] c = new int[10];
        long count = 0;
        for (int i = 1; i <= n; i++)
        {
            count -= n / i;
            c[i % 9]++;
        }
        for (int i = 0; i < 9; i++)
        {
            for (int j = 0; j < 9; j++)
            {
                count += (long)c[i] * (long)c[j] * (long)c[(i * j) % 9];
            }
        }
        Console.WriteLine(count);
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CodeForces
{
    static class Reader
    {
        public static int NextInt()
        {
            int ret = 0;
            char c;

            while (!char.IsDigit(c = (char)Console.Read()))
            {
                if (c == '-')
                    return -NextInt();
            }
            do
            {
                ret = ret * 10 + c - '0';
            } while (char.IsDigit(c = (char)Console.Read()));

            return ret;
        }

        public static double NextDouble()
        {
            double ret = 0;
            char c;

            while (!char.IsDigit(c = (char)Console.Read()))
            {
                if (c == '-')
                    return -NextDouble();
            }
            do
            {
                ret = ret * 10 + c - '0';
            } while (char.IsDigit(c = (char)Console.Read()));
            if (c != '.') return ret;

            double p10 = 0.1;
            while (char.IsDigit(c = (char)Console.Read()))
            {
                ret += p10 * (c - '0');
            }

            return ret;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            int N = Reader.NextInt();
            long S = 0;

            for (int A = 1; A <= N; ++A)
            {
                for (int B = 1; B <= 9; ++B)
                {
                    if (B > N)
                        continue;

                    int m = (N - B) / 9 + 1;
                    int k = N - A * B < 0 ? 0 : (N - A * B) / (9 * A) + 1;
                    int d = A * B % 9 == 0 ? 9 : A * B % 9;
                    int x = N - d < 0 ? 0 : (N - d) / 9 + 1;
                    S += (long)m * x - k;
                }
            }

            Console.WriteLine(S);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ProgrammingContest.Codeforces.Round10
{
    class C
    {
        public static long d(long x)
        {
            return x % 9;
        }

        public static void Main()
        {
            long n = long.Parse(Console.ReadLine());
            long ret = 0;
            long[] x = new long[9];
            for (int i = 1; i <= n; i++)
            {
                x[d(i)]++;
            }
            for (int a = 0; a < 9; a++)
            {
                for (int b = 0; b < 9; b++)
                {
                    ret += x[a] * x[b] * x[d(a * b)];
                    //Console.WriteLine("{0},{1},{2}:{3}", a, b, d(a * b), x[a] * x[b] * x[d(a * b)]);
                }
            }
            //Console.WriteLine(ret);
            for (long i = 1; i <= n; i++)
            {
                //ret -= n / i + (n % i == 0 ? 0 : 1);
                ret -= n / i;
            }
            Console.WriteLine(ret);
        }
    }
}

using System;

public class Solution {

    static int n;
    static int[] c;
    static int[] f;

    static int calc(int x) {
        if(x < 10) return x;
        else {
            int s = 0 ;
            while(x > 0) {
                s += x % 10;
                x /= 10;
            }
            return calc(s);
        }
    }

    public static void Main() {
        n = int.Parse(Console.ReadLine());
        c = new int[10];
        f = new int[1000];
        for(int i=1;i<1000;++i) f[i] = calc(i);
        for(int i=1;i<=n;++i) {
            int z = 0;
            if(i < 1000) z = f[i];
            else {
                int s = 0;
                int x = i;
                while(x > 0) {
                    s += x % 10;
                    x /= 10;
                }
                z = f[s];
            }
            ++c[z];
        }
        long res = 0;
        for(int i=1;i<10;++i)
            for(int j=1;j<10;++j) {
                res += (long)c[i] * c[j] * c[f[i*j]];
            }
        for(int i=1;i<=n;++i) {
            for(int j=1;i*j<=n;++j)
                --res;
        }
        Console.WriteLine(res);
    }
}

using System;
using System.Text;
using System.Collections;
using System.Collections.Generic;

class Program
{

    void solve()
    {

        long N = long.Parse(Console.ReadLine());
        long all = 0;
        long[] cnt = new long[9];
        for (int i = 1; i <= N; i++)
        {
            cnt[i % 9]++;
        }
        for (int i = 0; i < 9; i++)
        {
            long cnt1 = cnt[i];
            for (int j = 0; j < 9; j++)
            {
                long cnt2 = cnt[j];
                int k = (i * j) % 9;
                long cnt3 =cnt[k];
               all += cnt1 * cnt2 * cnt3;
            }
        }
        for (int i = 1; i <= N; i++)
        {
            all -= (N / i);
        }
        Console.WriteLine(all);

    }

    static void Main(string[] args)
    {
        new Program().solve();
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace acm
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = nextInt();
            long ans = 0;
            for (int i = 0; i < 9; ++i)
            {
                for (int j = 0; j < 9; j++)
                {
                    for (int k = 0; k < 9; k++) if( j * k % 9 == i )
                    {
                        ans += calc(j, n) * calc(k, n) * calc(i, n);
                    }
                }
            }
            int[] e = new int[n + 1];
            for (int i = 2; i < n + 1; i++)
            {
                if( e[i] == 0 )
                    for (int j = i + i; j < n + 1; j+=i)
                    {
                        e[j] = i;
                    }
            }
            -- ans;
            for (int i = 2; i < n + 1; i++) if (e[i] > 0)
                {
                    List<int> a = new List<int>();
                    int j;
                    for (j = i; e[j] != 0; j /= e[j]) a.Add(e[j]);
                    a.Add(j);
                    var l = from v in a orderby v select v;
                    long cnt = 1;
                    int lst = -1;
                    long cur = 0;
                    foreach (var z in l)
                    {
                        if (z != lst)
                        {
                            cnt *= (cur + 1);
                            cur = 0;
                        }
                        ++cur;
                        lst = z;
                    }
                    cnt *= (cur + 1);
                    //o(cnt);
                    ans -= cnt;
                }
                else ans -= 2;
            o(ans);
        }

        static long calc(int a, int n)
        {
            n -= a;
            if (a != 0) n += 9;
            return n / 9;
        }

        static string inp = null;
        static string[] inps = null;
        static int icur = -1;
        static string nextToken()
        {
            while (inps == null || icur == inps.Length)
            {
                icur = 0;
                inp = Console.ReadLine();
                inps = inp.Split(" \t".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            }
            return inps[icur++];
        }
        static int nextInt()
        {
            return int.Parse(nextToken());
        }
        static long nextLong()
        {
            return long.Parse(nextToken());
        }
        static double nextDouble()
        {
            return double.Parse(nextToken());
        }
        static void o( params object[] a )
        {
            Console.WriteLine(String.Join(" ", (from v in a select v.ToString()).ToArray()));
        }
    }
}

using System;
using System.Linq;
using System.IO;
using System.Collections.Generic;
// Powered by caide (code generator, tester, and library code inliner)

class Solution {
    long N;
    long[,] A;
    long[] B;
    public void solve(TextReader input, TextWriter output) {
        N = long.Parse(input.ReadLine());
        A = new long[10, 10];
        B = new long[10];
        for (int i = 0; i < 10; i++)
        {
            for (int j = 0; j < 10; j++)
            {
                A[i, j] = (i * j) % 9;
            }
        }

        for (int i = 1; i <= N; i++)
        {
            B[i % 9]++;
        }

        long X = 0;
        for (int i = 0; i < 10; i++)
        {
            for (int j = 0; j < 10; j++)
            {
                X += B[i] * B[j] * B[A[i, j]];
            }
        }

        long Y = 0;
        for (long i = 1; i <= N; i++)
        {
            Y += N / i;
        }

        output.WriteLine(X-Y);
    }

    public int d(int x)
    {
        int num = s(x);
        if (num <= 9)
            return num;
        return d(num);
    }

    private int s(int x)
    {
        int res = 0;
        while(x > 0)
        {
            res += x % 10;
            x /= 10;
        }

        return res;
    }
}

class CaideConstants {
    public const string InputFile = null;
    public const string OutputFile = null;
}
public class Program {
    public static void Main(string[] args) {
        Solution solution = new Solution();
        using (System.IO.TextReader input =
                CaideConstants.InputFile == null ? System.Console.In :
                        new System.IO.StreamReader(CaideConstants.InputFile))
        using (System.IO.TextWriter output =
                CaideConstants.OutputFile == null ? System.Console.Out:
                        new System.IO.StreamWriter(CaideConstants.OutputFile))

            solution.solve(input, output);
    }
}

#if DEBUG
using System.Reflection;
using System.Threading.Tasks;
#endif

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Numerics;
using System.Globalization;

namespace _10_c
{
    class Program
    {
        static string _inputFilename = "input.txt";
        static string _outputFilename = "output.txt";
        static bool _useFileInput = false;

        static void Main(string[] args)
        {
            StreamWriter file = null;
#if DEBUG
			Console.SetIn(getInput());
#else
            if (_useFileInput)
            {
                Console.SetIn(File.OpenText(_inputFilename));
                file = new StreamWriter(_outputFilename);
                Console.SetOut(file);
            }
#endif

            try
            {
                solution();
            }
            finally
            {
                if (_useFileInput)
                {
                    file.Close();
                }
            }
        }

        static void solution()
        {
            #region SOLUTION
            var n = readInt();
            var cs = new long[10];
            var vs = new long[n + 1];
            for (int i = 1; i < n + 1; i++)
            {
                vs[i] = getSum(i);
                cs[vs[i]]++;
            }

            var total = 0L;
            for (int i = 1; i < 10; i++)
            {
                for (int j = 1; j < 10; j++)
                {
                    var next = getSum(i * j);
                    var val = cs[i] * cs[j];
                    //if (i == j)
                    //{
                    //    val = cs[i] * cs[i - 1] / 2;
                    //}

                    if (val * cs[next] > 0)
                    {
                        total += val * cs[next];
                    }

                }
            }

            //total += (cs[1] * (cs[1] - 1) / 2);
            //total += (cs[2] * cs[1]);
            //total += (cs[3] * cs[1]);
            //total += (cs[4] * cs[1] + cs[2] * (cs[2] - 1) / 2);
            //total += (cs[5] * cs[1]);
            //total += (cs[6] * cs[1] + cs[3] * cs[2]);
            //total += (cs[7] * cs[1]);
            //total += (cs[8] * cs[1] + cs[2] * cs[4]);
            //total += (cs[9] * cs[1] + cs[3] * (cs[3] - 1) / 2);

            var remc = 0L;
            for (int i = 1; i < n + 1; i++)
            {
                remc += n / i;
            }
            //for (int i = 1; i < n + 1; i++)
            //{
            //    var end = (int)Math.Floor(Math.Sqrt(i));
            //    for (int j = 1; j <= end; j++)
            //    {
            //        var rem = i % j;
            //        var another = i / j;
            //        if (rem == 0)
            //        {
            //            if (another == j)
            //            {
            //                remc++;
            //            }
            //            else
            //            {
            //                remc += 2;
            //            }

            //        }
            //    }
            //}

            total -= remc;
            Console.WriteLine(total);

            //var n = readInt();
            //var m = readInt();

            //var a = readIntArray();
            //var b = readIntArray();
            #endregion
        }

        static int getSum(int a)
        {
            if (a < 10)
            {
                return a;
            }

            var val = a;
            var sum = 0;
            while (true)
            {
                sum += (val % 10);
                val /= 10;
                if (val == 0)
                {
                    break;
                }
            }

            return getSum(sum);
        }

        static int readInt()
        {
            return int.Parse(Console.ReadLine());
        }

        static long readLong()
        {
            return long.Parse(Console.ReadLine());
        }

        static int[] readIntArray()
        {
            return Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => int.Parse(i)).ToArray();
        }

        static long[] readLongArray()
        {
            return Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => long.Parse(i)).ToArray();
        }

#if DEBUG
		static StreamReader getInput()
		{
			var resName = Assembly.GetCallingAssembly().GetManifestResourceNames()[0];
			var resource = Assembly.GetCallingAssembly().GetManifestResourceStream(resName);

			return new StreamReader(resource);
		}
#endif
    }
}

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;

class Program
{
    public static int[] Read(string str)
    {
        string[] tokens = str.Trim().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
        int[] ret = new int[tokens.Length];
        for (int i = 0; i < ret.Length; i++)
        {
            ret[i] = int.Parse(tokens[i]);
        }

        return ret;
    }

    public static double[] ReadDouble(string str)
    {
        string[] tokens = str.Trim().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
        double[] ret = new double[tokens.Length];
        for (int i = 0; i < ret.Length; i++)
        {
            ret[i] = double.Parse(tokens[i], CultureInfo.InvariantCulture);
        }

        return ret;
    }

    static string Reverse(string s)
    {
        char[] a = s.ToCharArray();
        Array.Reverse(a);
        return new string(a);
    }

    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine().Trim());

        int[] c = new int[10];
        long count = 0;
        for (int i = 1; i <= n; i++)
        {
            count -= n / i;
            c[i % 9]++;
        }
        for (int i = 0; i < 9; i++)
        {
            for (int j = 0; j < 9; j++)
            {
                count += c[i] * c[j] * c[(i * j) % 9];
            }
        }
        Console.WriteLine(count);
    }
}

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;

class Program
{
    public static int[] Read(string str)
    {
        string[] tokens = str.Trim().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
        int[] ret = new int[tokens.Length];
        for (int i = 0; i < ret.Length; i++)
        {
            ret[i] = int.Parse(tokens[i]);
        }

        return ret;
    }

    public static double[] ReadDouble(string str)
    {
        string[] tokens = str.Trim().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
        double[] ret = new double[tokens.Length];
        for (int i = 0; i < ret.Length; i++)
        {
            ret[i] = double.Parse(tokens[i], CultureInfo.InvariantCulture);
        }

        return ret;
    }

    static string Reverse(string s)
    {
        char[] a = s.ToCharArray();
        Array.Reverse(a);
        return new string(a);
    }

    static int D(int d)
    {
        if (d < 10) return d;

        int sum = 0;
        while (d > 0)
        {
            sum += d % 10;
            d = d / 10;
        }

        return D(sum);
    }

    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine().Trim());
        long sum = 0;
        for (int i = 1; i <= n; i++)
        {
            int q = (int)Math.Sqrt(i);
            for (int j = 1; j <= q; j++)
            {
                if (i % j == 0)
                {
                    sum++;
                    if (j * j != i) sum++;
                }
            }
        }

        long count = 0;
        if (n >= 10)
        {
            count = n * n * n;
            count -= sum;
        }
        else
        {
            for (int a = 1; a <= n; a++)
            {
                for (int b = 1; b <= n; b++)
                {
                    int c = a * b;
                    if (c > n && D(c) <= n)
                    {
                        count++;
                    }
                }
            }
        }

        Console.WriteLine(count);
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ProgrammingContest.Codeforces.Round10
{
    class C
    {
        public static long d(long x)
        {
            return x % 9;
        }

        public static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            int ret = 0;
            int[] x = new int[9];
            for (int i = 1; i <= n; i++)
            {
                x[d(i)]++;
            }
            for (int a = 0; a < 9; a++)
            {
                for (int b = 0; b < 9; b++)
                {
                    ret += x[a] * x[b] * x[d(a * b)];
                    //Console.WriteLine("{0},{1},{2}:{3}", a, b, d(a * b), x[a] * x[b] * x[d(a * b)]);
                }
            }
            //Console.WriteLine(ret);
            for (int i = 1; i <= n; i++)
            {
                //ret -= n / i + (n % i == 0 ? 0 : 1);
                ret -= n / i;
            }
            Console.WriteLine(ret);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ProgrammingContest.Codeforces.Round10
{
    class C
    {
        public static long d(long x)
        {
            return x % 9;
        }

        public static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            int ret = 0;
            int[] x = new int[9];
            for (int i = 1; i <= n; i++)
            {
                x[d(i)]++;
            }
            for (int a = 0; a < 9; a++)
            {
                for (int b = 0; b < 9; b++)
                {
                    ret += x[a] * x[b] * x[d(a * b)];
                    //Console.WriteLine("{0},{1},{2}:{3}", a, b, d(a * b), x[a] * x[b] * x[d(a * b)]);
                }
            }
            Console.WriteLine(ret);
            for (int i = 1; i <= n; i++)
            {
                //ret -= n / i + (n % i == 0 ? 0 : 1);
                ret -= n / i;
            }
            Console.WriteLine(ret);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace acm
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = nextInt();
            long ans = 0;
            for (int i = 0; i < 9; ++i)
            {
                for (int j = 0; j < 9; j++)
                {
                    for (int k = 0; k < 9; k++) if( j * k % 9 == i )
                    {
                        ans += calc(j, n) * calc(k, n) * calc(i, n);
                    }
                }
            }
            int[] e = new int[n + 1];
            for (int i = 2; i < n + 1; i++)
            {
                if( e[i] == 0 )
                    for (int j = i + i; j < n + 1; j+=i)
                    {
                        e[j] = i;
                    }
            }
            -- ans;
            for (int i = 2; i < n + 1; i++) if (e[i] > 0)
                {
                    List<int> a = new List<int>();
                    int j;
                    for (j = i; e[j] != 0; j /= e[j]) a.Add(e[j]);
                    a.Add(j);
                    var l = from v in a orderby v select v;
                    long cnt = 1;
                    int lst = -1;
                    long cur = 0;
                    foreach (var z in l)
                    {
                        if (z != lst)
                        {
                            cnt *= (cur + 1);
                            cur = 0;
                        }
                        ++cnt;
                        lst = z;
                    }
                    cnt *= (cur + 1);
                    //o(cnt);
                    ans -= cnt;
                }
                else ans -= 2;
            o(ans);
        }

        static long calc(int a, int n)
        {
            n -= a;
            if (a != 0) n += 9;
            return n / 9;
        }

        static string inp = null;
        static string[] inps = null;
        static int icur = -1;
        static string nextToken()
        {
            while (inps == null || icur == inps.Length)
            {
                icur = 0;
                inp = Console.ReadLine();
                inps = inp.Split(" \t".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            }
            return inps[icur++];
        }
        static int nextInt()
        {
            return int.Parse(nextToken());
        }
        static long nextLong()
        {
            return long.Parse(nextToken());
        }
        static double nextDouble()
        {
            return double.Parse(nextToken());
        }
        static void o( params object[] a )
        {
            Console.WriteLine(String.Join(" ", (from v in a select v.ToString()).ToArray()));
        }
    }
}

#if DEBUG
using System.Reflection;
using System.Threading.Tasks;
#endif

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Numerics;
using System.Globalization;

namespace _10_c
{
    class Program
    {
        static string _inputFilename = "input.txt";
        static string _outputFilename = "output.txt";
        static bool _useFileInput = false;

        static void Main(string[] args)
        {
            StreamWriter file = null;
#if DEBUG
			Console.SetIn(getInput());
#else
            if (_useFileInput)
            {
                Console.SetIn(File.OpenText(_inputFilename));
                file = new StreamWriter(_outputFilename);
                Console.SetOut(file);
            }
#endif

            try
            {
                solution();
            }
            finally
            {
                if (_useFileInput)
                {
                    file.Close();
                }
            }
        }

        static void solution()
        {
            #region SOLUTION
            var n = readInt();
            var cs = new int[10];
            var vs = new int[n + 1];
            for (int i = 1; i < n + 1; i++)
            {
                vs[i] = getSum(i);
                cs[vs[i]]++;
            }

            var total = 0L;
            for (int i = 1; i < 10; i++)
            {
                for (int j = 1; j < 10; j++)
                {
                    var next = getSum(i * j);
                    var val = cs[i] * cs[j];
                    //if (i == j)
                    //{
                    //    val = cs[i] * cs[i - 1] / 2;
                    //}

                    if (val * cs[next] > 0)
                    {
                        total += val * cs[next];
                    }

                }
            }

            //total += (cs[1] * (cs[1] - 1) / 2);
            //total += (cs[2] * cs[1]);
            //total += (cs[3] * cs[1]);
            //total += (cs[4] * cs[1] + cs[2] * (cs[2] - 1) / 2);
            //total += (cs[5] * cs[1]);
            //total += (cs[6] * cs[1] + cs[3] * cs[2]);
            //total += (cs[7] * cs[1]);
            //total += (cs[8] * cs[1] + cs[2] * cs[4]);
            //total += (cs[9] * cs[1] + cs[3] * (cs[3] - 1) / 2);

            var remc = 0L;
            for (int i = 1; i < n + 1; i++)
            {
                var end = (int)Math.Floor(Math.Sqrt(i));
                for (int j = 1; j <= end; j++)
                {
                    var rem = i % j;
                    var another = i / j;
                    if (rem == 0)
                    {
                        if (another == j)
                        {
                            remc++;
                        }
                        else
                        {
                            remc += 2;
                        }

                    }
                }
            }

            total -= remc;
            Console.WriteLine(total);

            //var n = readInt();
            //var m = readInt();

            //var a = readIntArray();
            //var b = readIntArray();
            #endregion
        }

        static int getSum(int a)
        {
            if (a < 10)
            {
                return a;
            }

            var val = a;
            var sum = 0;
            while (true)
            {
                sum += (val % 10);
                val /= 10;
                if (val == 0)
                {
                    break;
                }
            }

            return getSum(sum);
        }

        static int readInt()
        {
            return int.Parse(Console.ReadLine());
        }

        static long readLong()
        {
            return long.Parse(Console.ReadLine());
        }

        static int[] readIntArray()
        {
            return Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => int.Parse(i)).ToArray();
        }

        static long[] readLongArray()
        {
            return Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => long.Parse(i)).ToArray();
        }

#if DEBUG
		static StreamReader getInput()
		{
			var resName = Assembly.GetCallingAssembly().GetManifestResourceNames()[0];
			var resource = Assembly.GetCallingAssembly().GetManifestResourceStream(resName);

			return new StreamReader(resource);
		}
#endif
    }
}

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Numerics;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {

        private static int CalcD(int num)
        {
            var s = num.ToString().Sum(ch => (int)char.GetNumericValue(ch));
            if (s <= 9)
            {
                return s;
            }
            else
            {
                return CalcD(s);
            }
        }

        static void Main(string[] args)
        {
            var nInt = Convert.ToInt32(Console.ReadLine());

            var n = new BigInteger(nInt);
            BigInteger errors = 0;

            BigInteger c = 0;

            for (int i = 1; i < n; i++)
            {
                if (n < i * i)
                {
                    break;
                }
                else
                {
                    for (int j = i; n >= j * i; j++)
                    {
                        if (i == j)
                        {
                            c++;
                        }
                        else
                        {
                            c += 2;
                        }
                    }
                }
            }

            var max = n > 9 ? 9 : n;
            for (int A = 1; A <= max; A++)
            {
                for (int B = 1; B <= max; B++)
                {
                    for (int C = 1; C <= max; C++)
                    {
                        if (C == CalcD(A * B))
                        {
                            BigInteger tmp = ((((n - C)/9) + 1)*(((n - A)/9) + 1)*(((n - B)/9) + 1));
                            errors += tmp;
                        }

                    }
                }
            }

            Console.WriteLine(errors - c);
            //Console.ReadKey();
        }
    }
}