using System; using System.Collections.Generic; using System.Linq; using static System.Console; class Program { static void Main() { WriteLine(ReadLine().Split().Select(int.Parse).Sum(x => x % 15 == 0 ? 8 : x % 5 == 0 || x % 3 == 0 ? 4 : x.ToString().Length)); } }