using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Isplata
{
    class Program
    {
        static void Main(string[] args)
        {
            string V = Console.ReadLine();
            Int64 V1 = int.Parse(V);
            Int64 l = V.Length;
            int [,] d = { { 1, 2, 5 } };
            Int64 k;
            double s1 = 0;
            double s2 = 0;
            Int64 br1 = 0;
            Int64 br2 = 0;
            double n;
            for (int i = 1; i > 0; i--)
            {
                for (int j = 3; j > 0; j--)
                {
                    k = l - (l - 1);
                    n = (d[i, j]) * (Math.Pow(10, k));
                    while ((s1 + d[i, j]) < V1 && n <= V1)
                    {
                        br1++;
                        s1 += n;
                    }
                    s2 = s1;
                }
            }
            for(int i = 1; i > 0; i--)
            {
                for(int j = 3; j > 0; j--)
                {
                    k = l - (l - 2);
                    n = (d[i, j]) * (Math.Pow(10, k));
                    while (s2 + n <= V1)
                    {
                        br2++;
                        s2 += n;
                    }
                }
            }
            Int64 br = br1 + br2;
            Console.WriteLine(br);
        }
    }
}