using System;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int i,j, s = 0;
            double[] d = { 5, 2, 1 };
            string V1 = Console.ReadLine();
            double k = V1.Length;
            k--;
            double V = Convert.ToInt32(V1);
            double[] Varr = new double[20];
            double m = k;
            for (i = 0; i < k; i++){
                Varr[i] = Math.Truncate(V / (Math.Pow(10, m)));
                V = V - Varr[i] * Math.Pow(10, m);
                m--;
            }

            for (i = 0; i < k; i++)
            {
                Console.Write(Varr[i] + ", ");
            }

            Console.WriteLine();
             for (i = 0; i < k; i++) {
                 for (j = 0; j < 3; ) {
                     if (Varr[i] - d[j] >= 0)
                     {
                         Varr[i] -= d[j];
                         s++;
                     }
                     else
                         j++;
                 }
                 
              }
            Console.WriteLine(s);
        }
    }
}