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

namespace Codeforces
{
    class Program : ProgramBase
    {
        private const long commonMod = 1000000007;

        static void Main(string[] args)
        {
            var p = new Program();

            var x = p.Solve();
            p.Out(x);
        }
        object Solve()
        {
            var n = ReadLong();
            var result = 0L;
            for (int i = 0; i < n; i++)
            {
                var s = Read();
                switch (s)
                {
                    case "Tetrahedron":
                        result += 4;
                        break;
                    case "Cube":
                        result += 6;
                        break;
                    case "Octahedron":
                        result += 8;
                        break;
                    case "Dodecahedron":
                        result += 12;
                        break;
                    case "Icosahedron":
                        result += 20;
                        break;
                    default:
                        break;
                }
            }
            return result;
        }

        int BS(List<int> list, int i)
        {
            if (list[0] > i)
                return 0;
            if (list.Last() <= i)
                return list.Count;
            return BS(list, i, 0, list.Count - 1);
        }
        int BS(List<int> list, int v, int left, int right)
        {
            if (right - left == 1)
                return left + 1;
            var h = (left + right) / 2;
            if (list[h] == v)
                return h + 1;
            if (list[h] < v)
                return BS(list, v, h, right);
            return BS(list, v, left, h);
        }

        class Pair
        {
            public long Val;
            public long Rem;
            public long Count1;
            public long Len;
        }

        Node FindDeepest(Node current, long target, Node bad)
        {
            Node result = null;
            for (int i = 0; i < current.Children.Count; i++)
            {
                if (current.Children[i] == bad)
                    continue;
                result = FindDeepest(current.Children[i], target, bad);
                if (result != null)
                {
                    break;
                }
            }
            if (current.parent != -1 && result == null && current.sum == target)
                return current;
            return result;
        }

        long CalcSum(Node current)
        {
            var sum = current.t;
            for (int i = 0; i < current.Children.Count; i++)
            {
                sum += CalcSum(current.Children[i]);
            }
            current.sum = sum;
            return sum;
        }

        class Node {
            public long parent;
            public long index;
            public long t;
            public long sum;
            public List<Node> Children;
        }
    }

    abstract class ProgramBase
    {
        bool? prod = null;
        StreamReader f;
        Queue<string> tokens;
        protected string FileName { private get; set; }

        protected string Read()
        {
            if (f == null)
                f = string.IsNullOrEmpty(FileName)
                    ? new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024 * 10)
                    : new StreamReader((GetProd() ? "" : "c:\\dev\\") + FileName);
            return f.ReadLine();
        }

        protected string ReadToken()
        {
            if (tokens == null || tokens.Count == 0)
                tokens = new Queue<string>(Read().Split(' '));
            return tokens.Dequeue();
        }

        protected long ReadLong() { return long.Parse(ReadToken()); }

        protected long[] ReadLongs()
        {
            var s = Read();
            if (s == "")
                return new long[0];
            //var i = s.IndexOf(' ');
            //return new[] { long.Parse(s.Substring(0, i)), long.Parse(s.Substring(i + 1)) };
            var tokens = s.Split(' ');
            var result = new long[tokens.Length];
            for (int i = 0; i < tokens.Length; i++)
                result[i] = long.Parse(tokens[i]);
            return result;
        }

        public void Out(object r)
        {
            if (string.IsNullOrEmpty(FileName))
                Console.WriteLine(r);
            else if (GetProd())
                File.WriteAllText(FileName, r.ToString());
            else
                Console.WriteLine(r);
        }

        private bool GetProd()
        {

            if (!prod.HasValue)
                try
                {
                    prod = Environment.MachineName != "RENADEEN-W7";
                }
                catch (Exception)
                {
                    prod = true;
                }
            return prod.Value;
        }
    }

    public static class Huj
    {
        public static T MinBy<T>(this IEnumerable<T> source, Func<T, double> func) where T : class
        {
            T result = null;
            var min = double.MaxValue;
            foreach (var item in source)
            {
                var current = func(item);
                if (min > current)
                {
                    min = current;
                    result = item;
                }
            }
            return result;
        }

        public static T MaxBy<T>(this IEnumerable<T> source, Func<T, double> func, T defaultValue = default(T))
        {
            T result = defaultValue;
            var max = double.MinValue;
            foreach (var item in source)
            {
                var current = func(item);
                if (max < current)
                {
                    max = current;
                    result = item;
                }
            }
            return result;
        }

        public static string JoinStrings(this IEnumerable<string> s, string d) { return string.Join(d, s.ToArray()); }

        public static string JoinStrings(this IEnumerable<int> s, string d) { return s.Select(x => x.ToString()).JoinStrings(d); }
        public static string JoinStrings(this IEnumerable<long> s, string d) { return s.Select(x => x.ToString()).JoinStrings(d); }
    }
}


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

namespace CF317
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var sr = new InputReader(Console.In);
            //var sr = new InputReader(new StreamReader("input.txt"));
            var task = new Task();
            using (var sw = Console.Out)
            {
                //using (var sw = new StreamWriter("output.txt")) {
                task.Solve(sr, sw);
                //Console.ReadKey();
            }
        }
    }

    internal class Task
    {
        public void Solve(InputReader sr, TextWriter sw)
        {
            var dict = new Dictionary<string, int> {
                { "Tetrahedron", 4 },
                { "Cube", 6 },
                { "Octahedron", 8 },
                { "Dodecahedron", 12 },
                { "Icosahedron", 20 },
            };
            var n = sr.NextInt32();
            var count = 0;
            for (var i = 0; i < n; i++) {
                var next = sr.NextString();
                count += dict[next];
            }

            sw.Write(count);
        }
    }
}

internal class InputReader : IDisposable
{
    private bool isDispose;
    private readonly TextReader sr;

    public InputReader(TextReader stream)
    {
        sr = stream;
    }

    public void Dispose()
    {
        Dispose(true);
        GC.SuppressFinalize(this);
    }

    public string NextString()
    {
        var result = sr.ReadLine();
        return result;
    }

    public int NextInt32()
    {
        return Int32.Parse(NextString());
    }

    public long NextInt64()
    {
        return Int64.Parse(NextString());
    }

    public string[] NextSplitStrings()
    {
        return NextString()
                .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
    }

    public T[] ReadArray<T>(Func<string, CultureInfo, T> func)
    {
        return NextSplitStrings()
                .Select(s => func(s, CultureInfo.InvariantCulture))
                .ToArray();
    }

    public T[] ReadArrayFromString<T>(Func<string, CultureInfo, T> func, string str)
    {
        return
                str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                        .Select(s => func(s, CultureInfo.InvariantCulture))
                        .ToArray();
    }

    protected void Dispose(bool dispose)
    {
        if (!isDispose)
        {
            if (dispose)
                sr.Close();
            isDispose = true;
        }
    }

    ~InputReader()
    {
        Dispose(false);
    }
}


using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace _100853_Codeforce
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = new StreamReader(Console.OpenStandardInput());

            int N = int.Parse(input.ReadLine());

            int a1 = int.MinValue;
            int a2 = int.MaxValue;

            for (int i = 0; i < N; ++i)
            {
                string[] temp = input.ReadLine().Split(' ');

                int x1 = int.Parse(temp[0]);
                int x2 = int.Parse(temp[1]);

                if (a1 < x1)
                    a1 = x1;
                if (a2 > x2)
                    a2 = x2;
            }

            int m = int.Parse(input.ReadLine());

            int b1 = int.MinValue;
            int b2 = int.MaxValue;

            for (int i = 0; i < m; ++i)
            {
                string[] temp = input.ReadLine().Split(' ');

                int x1 = int.Parse(temp[0]);
                int x2 = int.Parse(temp[1]);

                if (b1 < x1)
                    b1 = x1;
                if (b2 > x2)
                    b2 = x2;
            }

            input.Close();

            int delta1 = a1 - b2;
            if (delta1 < 0)
                delta1 = 0;

            int delta2 = b1 - a2;
            if (delta2 < 0)
                delta2 = 0;

            using (var output = new StreamWriter(Console.OpenStandardOutput()))
                output.Write((delta1 > delta2) ? delta1 : delta2);

        }

    }
}


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

namespace _100853_Codeforce
{
    class Program
    {
        static void Main(string[] args)
        {
            Dictionary<string, int> dic = new Dictionary<string, int>();
            dic.Add("Tetrahedron", 4);
            dic.Add("Cube", 6);
            dic.Add("Octahedron", 8);
            dic.Add("Dodecahedron", 12);
            dic.Add("Icosahedron", 20);
            int sum = 0;
            int n = Convert.ToInt32(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                string key = Console.ReadLine();
                sum += dic[key];
            }
            Console.WriteLine(sum);

        }

    }
}


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

namespace A_Anton_and_figures
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int sum = 0;
            for (int i = 0; i < n; i++)
            {
                switch (Console.ReadLine())
                {
                    case "Tetrahedron": sum += 4;break;
                    case "Cube": sum += 6; break;
                    case "Octahedron": sum += 8; break;
                    case "Dodecahedron": sum += 12; break;
                    case "Icosahedron": sum +=20; break;
                }
            }
            Console.WriteLine(sum);
        }
    }
}


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

namespace _781A
{
    class Program
    {
        static void Main(string[] args)
        {
            int x = int.Parse(Console.ReadLine());
            int s = 0;
            for(int i = 0; i<x;i++)
            {
                string b = Console.ReadLine();
                switch(b)
                {
                    case "Tetrahedron": s += 4; break;
                    case "Cube": s +=6; break;
                    case "Octahedron": s += 8; break;
                    case "Dodecahedron": s += 12; break;
                    case "Icosahedron": s +=20; break;
                }
            }
            Console.WriteLine(s);
        }
    }
}


using System;
using System.IO;

namespace Issue_785A
{
    public static class Program
    {
        public static void Main(string[] args) {
            var count = IO.Read();

            var edges = 0;

            for (var i = 0; i < count; ++i) {
                var figure = IO.ReadLine();

                edges += EdgesByFigure(figure);
            }

            Console.WriteLine(edges);
        }

        private static int EdgesByFigure(string figure) {
            var letter = figure[0];

            switch (letter)
            {
                case 'T': return 4;
                case 'C': return 6;
                case 'O': return 8;
                case 'D': return 12;
                case 'I': return 20;
            }

            throw new Exception("What the fuck");
        }
    }

    public static class IO {
        public const int ZeroCode = (int) '0';

        static IO() {
            Reader = new StreamReader(
                Console.OpenStandardInput(sizeof(int)),
                System.Text.Encoding.ASCII,
                false,
                sizeof(int),
                false);
        }

        public static StreamReader Reader {
            get; set;
        }

        public static string ReadLine() {
            return Reader.ReadLine();
        }

        public static int Read() {
            var reader = Reader;
            var symbol = reader.Read();

            while (symbol == ' ') {
                symbol = reader.Read();
            }

            var isNegative = false;
            if (symbol == '-') {
                isNegative = true;
                symbol = reader.Read();
            }

            int result = 0;
            for ( ;
                (symbol != -1) && (symbol != ' ');
                symbol = reader.Read()
            ) {
                var digit = symbol - ZeroCode;

                if (digit < 10 && digit >= 0) {
                    result = (result << 1) + ((result << 1) << 2) + digit;
                } else {
                    if (symbol == 13)         // if symbol == \n
                        reader.Read();        // skip next \r symbol
                    break;
                }
            }

            return isNegative ? ~result + 1 : result;
        }
    }
}


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

namespace ex_A
{
    class Program
    {
        static void Main(string[] args)
        {
            int counter = 0;
            int n = 0;
            n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                switch (Console.ReadLine())
                {
                    case "Tetrahedron":
                        counter += 4;
                        break;
                    case "Cube":
                        counter += 6;
                        break;
                    case "Octahedron":
                        counter += 8;
                        break;
                    case "Dodecahedron":
                        counter += 12;
                        break;
                    case "Icosahedron":
                        counter += 20;
                        break;
                }
            }
            Console.WriteLine(counter);

        }
    }
}


using System;
using System.Collections.Generic;

namespace Test
{
	public class Program
	{
		public static void Main()
		{
			Dictionary<string, int> collection = new Dictionary<string, int>();
			collection.Add("Tetrahedron", 4);
			collection.Add("Cube", 6);
			collection.Add("Octahedron", 8);
			collection.Add("Dodecahedron", 12);
			collection.Add("Icosahedron", 20);
			int sum = 0;
			int n = Convert.ToInt32(Console.ReadLine());
			for (int i = 0; i < n; i++)
			{
				string key = Console.ReadLine();
				sum += collection[key];
			}
			Console.WriteLine(sum);
			Console.ReadLine();
		}
	}
}


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

namespace ConsoleApplication254
{
    class Program
    {

        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            long t = 0;
            for (int i = 0; i < n; i++)
            {
                string s = Console.ReadLine();
                if (s[0] == 'I') t += 20;
                else
                    if (s[0] == 'D') t += 12;
                    else
                        if (s[0] == 'O') t += 8;
                        else
                            if (s[0] == 'C') t += 6;
                            else
                                t += 4;
            }
            Console.WriteLine(t);

        }
    }
}/*using System;
using System.Collections.Generic;
using System.Text;

namespace chislo
{
    class Program
    {
        static void Main(string[] args)
        {int sch = 0;
            string[] s = Console.ReadLine().Split(' ');
            long n = Convert.ToInt64(s[0]);
            long l1 = Convert.ToInt64(s[1]);
            long r1 = Convert.ToInt64(s[2]);
            List<long> l = new List<long>(); if (n == 0) Console.WriteLine(0);
            else
                if (n == 1)
                {
                    if (l1 <= 2 && r1 >= 2) Console.WriteLine(1);
                    else
                        Console.WriteLine(0);
                }
                else
            {
                for (int i = 0; n > 1; i++)
                {
                    l.Add(n); n /= 2;
                }
                string c = Convert.ToString(l[l.Count - 1] / 2);
                string c1 = Convert.ToString(l[l.Count - 1] % 2);
                string str = (c + c1 + c);
                for (int i = l.Count - 2; i >= 0; i--)
                {
                    c1 = Convert.ToString(l[i] % 2);
                    str += c1 + str;
                }
                Console.WriteLine(str);

                /*for (long i = l1 - 1; i < r1; i++)
                {
                    if (str[i] == '1') sch++;
                }
                 Console.WriteLine(str);
                Console.WriteLine(sch);

            }

        }
    }
}*/


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

namespace denemeX
{
    class Program
    {
        static void Main(string[] args)
        {
            try {
                int n = int.Parse(Console.ReadLine());
                int sum = 0;
                for (int i = 0; i < n; i++)
                {
                    switch (Console.ReadLine())
                    {
                        case "Tetrahedron":
                            sum += 4;
                            break;
                        case "Cube":
                            sum += 6;
                            break;
                        case "Octahedron":
                            sum += 8;
                            break;
                        case "Dodecahedron":
                            sum += 12;
                            break;
                        case "Icosahedron":
                            sum += 20;
                            break;
                    }

                }
                Console.Write(sum);
                Console.ReadKey();
            }
            catch { }
        }

    }
}


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

namespace ConsoleApplication1A
{
  class ProgramAAA
  {
    static void Main(string[] args)
    {

      int n = Convert.ToInt32(Console.ReadLine());
      Int64 r = 0;

      for (var i = 0; i < n; i++)
      {
        var s = Console.ReadLine();
        if (s == "Tetrahedron") r = r + 4;
        if (s == "Cube") r = r + 6;
        if (s == "Octahedron") r = r + 8;
        if (s == "Dodecahedron") r = r + 12;
        if (s == "Icosahedron") r = r + 20;
      }

      Console.WriteLine(r);
    }

  }
}


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

public class Polyhedron{
   public int getFaces(string nm){
      int nf = 0;
      switch(nm){
         case "Tetrahedron":
	    nf = 4;
	    break;
	 case "Cube":
	    nf = 6;
	    break;
	 case "Octahedron":
	    nf = 8;
	    break;
	 case "Dodecahedron":
	    nf = 12;
	    break;
	 case "Icosahedron":
	    nf = 20;
	    break;
      }
      return nf;
   }

   public static void Main(string[] args){
      try{
         StreamReader sr = new StreamReader(Console.OpenStandardInput());
	 StreamWriter sw = new StreamWriter(Console.OpenStandardOutput());
	 string nLn, pLn;
	 nLn = sr.ReadLine();
	 int np = int.Parse(nLn);
	 Polyhedron p = new Polyhedron();
	 int nFaces = 0;
	 for(int i=0;i<np;i++){
	    pLn = sr.ReadLine();
	    nFaces += p.getFaces(pLn);
	 }
	 sw.WriteLine(nFaces);
	 sw.Flush();
      }catch(Exception e){
         Console.WriteLine(e.StackTrace);
      }
   }

}


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

namespace Vkcup {
    class Program {
        static void Main(string[] args) {
            int a, res;
            res = 0;
            a = Convert.ToInt32(Console.ReadLine());
            for(int i = 0; i < a; ++i) {
                string s = Console.ReadLine();
                if (s ==("Tetrahedron")) res += 4;
                if (s == ("Cube")) res += 6;
                if (s == ("Octahedron")) res += 8;
                if (s == ("Dodecahedron")) res += 12;
                if (s == ("Icosahedron")) res += 20;

            }
            Console.WriteLine(res);

        }
    }
}


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

namespace A.Anton_and_Polyhedrons
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[]c= new string[n];
            long cou = 0;
            for (int i = 0; i < n; i++)
            {
                c[i] = Console.ReadLine();
                if (c[i]=="Tetrahedron")
                {
                    cou += 4;
                }
                else if (c[i]=="Cube")
                {
                    cou +=6;
                }
                else if (c[i]=="Octahedron")
                {
                    cou += 8;
                }
                else if (c[i]=="Dodecahedron")
                {
                    cou += 12;
                }
                else
                {
                    cou += 20;
                }
            }
            Console.WriteLine(cou);
        }
    }
}


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

namespace A.Anton_and_Polyhedrons
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[]c= new string[n];
            int cou = 0;
            for (int i = 0; i < n; i++)
            {
                c[i] = Console.ReadLine();
                if (c[i]=="Tetrahedron")
                {
                    cou += 4;
                }
                else if (c[i]=="Cube")
                {
                    cou += 4;
                }
                else if (c[i]=="Octahedron")
                {
                    cou += 8;
                }
                else if (c[i]=="Dodecahedron")
                {
                    cou += 12;
                }
                else
                {
                    cou += 20;
                }
            }
            Console.WriteLine(cou);
        }
    }
}


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

namespace A.Anton_and_Polyhedrons
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[]c= new string[n];
            int cou = 0;
            for (int i = 0; i < n; i++)
            {
                c[i] = Console.ReadLine();
                if (c[i]=="Tetrahedron")
                {
                    cou += 4;
                }
                 if (c[i]=="Cube")
                {
                    cou += 4;
                }
                 if (c[i]=="Octahedron")
                {
                    cou += 8;
                }
                 if (c[i]=="Dodecahedron")
                {
                    cou += 12;
                }
                else
                {
                    cou += 20;
                }
            }
            Console.WriteLine(cou);
        }
    }
}


using System;

namespace tmpRound2
{
    class Program
    {
        static int Main(string[] args)
        {

            int n = int.Parse(Console.ReadLine()), sum = 0;
            for (int i = 0; i < n; i++)
            {
                string str = Console.ReadLine();
                if (Equals(str, "Tetrahedron"))
                    sum += 4;
                else if (Equals(str, "Cube"))
                    sum += 6;
                else if (Equals(str, "Octahedron"))
                    sum += 8;
                else if (Equals(str, "Dodecahedron"))
                    sum += 12;
                else if (Equals(str, "Icosahedron"))
                    sum += 20;
            }
            Console.WriteLine(sum);
            return 0;
        }
    }
}


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

namespace ConsoleApplication1.CodeForces
{
    class _403
    {

        static void Main(String[] args)
        {
            var n = int.Parse(Console.ReadLine());
            long result = 0;
            for (var i = 0; i < n; i++)
            {
                var line = Console.ReadLine();
                switch (line)
                {
                    case "Tetrahedron":
                        result += 4;
                        break;
                    case "Cube":
                        result += 6;
                        break;
                    case "Octahedron":
                        result += 8;
                        break;
                    case "Dodecahedron":
                        result += 12;
                        break;
                    case "Icosahedron":
                        result += 20;
                        break;
                }

            }
            Console.WriteLine(result);
        }
    }
}


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

namespace Application
{
    class Program
    {
        static void Main(string[] args)
        {
            string inputNum = Console.ReadLine();

            string[] inputString = new string[int.Parse(inputNum)];

            for (var i = 0; i < int.Parse(inputNum); i++)
            {
                inputString[i] = Console.ReadLine();
            }

            var dict = new Dictionary<string, int>();

            dict.Add("Tetrahedron", 4);
            dict.Add("Cube", 6);
            dict.Add("Octahedron", 8);
            dict.Add("Dodecahedron", 12);
            dict.Add("Icosahedron", 20);

            int sum = default(int);

            for (var i = 0; i < inputString.Length; i++)
            {
                if (dict.ContainsKey(inputString[i].ToString())) sum += dict[inputString[i].ToString()];
            }

            Console.WriteLine(sum);
        }
    }
}


using System;

namespace Application
{
    class Program
    {
        static void Main(string[] args)
        {
            int inputNum = int.Parse(Console.ReadLine());

            string[] inputString = new string[inputNum];

            for (var i = 0; i < inputString.Length; i++)
            {
                inputString[i] = Console.ReadLine();
            }

            var dict = new Dictionary<string, int>();

            dict.Add("Tetrahedron", 4);
            dict.Add("Cube", 6);
            dict.Add("Octahedron", 8);
            dict.Add("Dodecahedron", 12);
            dict.Add("Icosahedron", 20);

            int sum = default(int);

            for (var i = 0; i < inputNum; i++)
            {
                if (dict.ContainsKey(inputString[i].ToString())) sum += dict[inputString[i].ToString()];
            }

            Console.WriteLine(sum);
        }
    }
}


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

namespace Contest
{
	class Program
	{
		static void Main(string[] args)
		{
			var polyhedrons = new Dictionary<string, int>();
			polyhedrons["Tetrahedron"] = 4;
			polyhedrons["Cube"] = 6;
			polyhedrons["Octahedron"] = 8;
			polyhedrons["Dodecahedron"] = 12;
			polyhedrons["Icosahedron"] = 20;
			int n = int.Parse(Console.ReadLine());
			int ans = 0;
			for (int i = 0; i < n; i++)
			{
				ans += polyhedrons[Console.ReadLine()];
			}
			Console.WriteLine(ans);
		}
	}
}


using System;

namespace CodeForces
{
    class Program
    {
        static void Main(string[] args)
        {
            int n,s=0;

            n = Convert.ToInt32(Console.ReadLine());

            for (int i = 0; i < n; i++)
            {
                string c = Console.ReadLine();
                switch(c.Length)
                {
                    case 11://tetra
                        if (c[0] == 'T')
                            s += 4;
                        else
                            s += 20;
                            break;
                    case 4://cube;s
                        s += 6;
                        break;
                    case 10://octa
                        s += 8;
                        break;
                    case 12://dode
                        s += 12;
                        break;
                }
            }

            Console.WriteLine(s);
        }
    }
}


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

class PairVariable : IComparable<PairVariable>
{
    public int a, b;
    public PairVariable()
    {
        a = b = 0;
    }
    public PairVariable(string s)
    {
        string[] q = s.Split();
        a = int.Parse(q[0]);
        b = int.Parse(q[1]);
    }
    public PairVariable(int a, int b)
    {
        this.a = a;
        this.b = b;
    }
    public int CompareTo(PairVariable pv)
    {
        if (this.a > pv.a)
        {
            return 1;
        }
        else if (this.a < pv.a)
        {
            return -1;
        }
        else
        {
            if (this.b >= pv.b)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
    }

}
namespace ConsoleApplication254
{
    class Program
    {

        static void Main(string[] args)
        {
            string[] ss = Console.ReadLine().Split();
            int n = int.Parse(ss[0]);
            long ans = 0;
            for (int i = 0; i < n; i++)
            {
                string a = Console.ReadLine();
                if (a == "Tetrahedron")
                {
                    ans += 4;
                }
                else if (a == "Cube")
                {
                    ans += 6;
                }
                else if (a == "Octahedron")
                {
                    ans += 8;
                }
                else if (a == "Dodecahedron")
                {
                    ans += 12;
                }
                else if (a == "Icosahedron")
                {
                    ans += 20;
                }
                Console.WriteLine(ans);

            }

        }
    }
}


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

class PairVariable : IComparable<PairVariable>
{
    public int a, b;
    public PairVariable()
    {
        a = b = 0;
    }
    public PairVariable(string s)
    {
        string[] q = s.Split();
        a = int.Parse(q[0]);
        b = int.Parse(q[1]);
    }
    public PairVariable(int a, int b)
    {
        this.a = a;
        this.b = b;
    }
    public int CompareTo(PairVariable pv)
    {
        if (this.a > pv.a)
        {
            return 1;
        }
        else if (this.a < pv.a)
        {
            return -1;
        }
        else
        {
            if (this.b >= pv.b)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
    }

}
namespace ConsoleApplication254
{
    class Program
    {

        static void Main(string[] args)
        {
            string[] ss = Console.ReadLine().Split();
            int n = int.Parse(ss[0]);
            long ans = 0;
            for (int i = 0; i < n; i++)
            {
                string a = Console.ReadLine();
                if (a == "Tetrahedron")
                {
                    ans += 4;
                }
                else if (a == "Cube")
                {
                    ans += 6;
                }
                else if (a == "Octahedron")
                {
                    ans += 8;
                }
                else if (a == "Dodecahedron")
                {
                    ans += 12;
                }
                else if (a == "Icosahedron")
                {
                    ans += 20;
                }

            }

            Console.WriteLine(ans);

        }
    }
}


using System;
using System.Collections.Generic;

namespace A785{
	class Program{
		static void Main(string[] args){
            int n = int.Parse(Console.ReadLine());
            int count = 0;
            for (int i = 0; i < n; i++)
            {
                string s = Console.ReadLine();
                switch (s[0])
                {
                    case 'T':
                        count += 4;
                        break;
                    case 'C':
                        count += 6;
                        break;
                    case 'O':
                        count += 8;
                        break;
                    case 'D':
                        count += 12;
                        break;
                    case 'I':
                        count += 20;
                        break;
                    default:
                        break;
                }
            }
            Console.WriteLine(count);
		}
	}
}


//Rextester.Program.Main is the entry point for your code. Don't change it.
//Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5

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

namespace Rextester
{
    public class Program
    {
        public static void Main(string[] args)
        {
            int N=Convert.ToInt32(Console.ReadLine());
            long result=0;
            for(int i=0;i<N;i++)
            {
                string input=Console.ReadLine();
                result=(input=="Icosahedron")?result+20:(input=="Cube")?result+6:(input=="Tetrahedron")?result+4:(input=="Dodecahedron")?result+12:result+8;
            }
            Console.WriteLine(result);
        }
    }
}


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

// codeforces 785A

namespace cfcs
{

    class Program
    {

        private void solve()
        {
            int s = 0;
            var n = uint.Parse(Console.ReadLine());

            for (int i = 0; i < n; i++)
            {
                switch (Console.ReadLine())
                {
                    case "Tetrahedron":
                        s += 4;
                        break;
                    case "Cube":
                        s += 6;
                        break;
                    case "Octahedron":
                        s += 8;
                        break;
                    case "Dodecahedron":
                        s += 12;
                        break;
                    case "Icosahedron":
                        s += 20;
                        break;
                }
            }

            Console.WriteLine("{0}", s);
        }

        [Conditional("DEBUG")]
        void DebugInformation()
        {
            Console.Write("\n[DebugInformation]\n");
            Console.ReadKey(true);
        }

        static void Main()
        {
            //System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
            Program app = new Program();
            app.solve();
            app.DebugInformation();
        }
    }
}


using System;
using System.IO;

static class Program
{
	static void Main ()
	{
		var input = new StreamReader(Console.OpenStandardInput());

		int n = int.Parse(input.ReadLine());

		int sum = 0;

		for (int i = 0; i < n; ++i)
		{
			switch (input.ReadLine())
			{
				case "Tetrahedron":
					sum += 4;
					break;
				case "Cube":
					sum += 6;
					break;
				case "Octahedron":
					sum += 8;
					break;
				case "Dodecahedron":
					sum += 12;
					break;
				case "Icosahedron":
					sum += 20;
					break;
			}
		}

		input.Close();

		using (var output = new StreamWriter(Console.OpenStandardOutput()))
			output.Write(sum);
	}
}


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

namespace contest
{

    class contest
    {
        int[] dx = new int[] { 1, 0, -1, 0 };
        int[] dy = new int[] { 0, 1, 0, -1 };

        static void Main(string[] args)
        {

            //Console.WriteLine();

            //int n = int.Parse(Console.ReadLine());
            //var num = Console.ReadLine().Split().Select(int.Parse).ToArray();

            //var arr = new int[n][];
            //for(int i =0; i< n; i++)
            //{
            //    arr[i] = Console.ReadLine().Split().Select(int.Parse).ToArray();
            //}

            //var num = Console.ReadLine().Split().Select(int.Parse).ToArray();
            //int n = num[0];
            //int m = num[1];

            #region

            int n = int.Parse(Console.ReadLine());
            var q = new string[n];
            for (int i = 0; i < n; i++)
            {
                q[i] = Console.ReadLine();
            }

            var dic = new Dictionary<char, int>();
            dic['t'] = 4;
            dic['c'] = 6;
            dic['o'] = 8;
            dic['d'] = 12;
            dic['i'] = 20;
            int ans = 0;
            for (int i = 0; i < n; i++)
            {
                string str = q[i];
                char c = str.ToLower()[0];
                ans += dic[c];
            }

            Console.WriteLine(ans);

            #endregion

            //Console.WriteLine();

        }

    }

    class Segment
    {
        public long[] arr;

        public long n;
        HashSet<long> list = new HashSet<long>();
        //public List<long> q = new List<long>();
        public int count = 0;

        public Segment(long m, long k)
        {
            this.n = m;
            //arr = Enumerable.Range(0, n*2).ToArray();
            arr = new long[n * 4];

            for (int i = 0; i < n * 4; i++)
            {
                //arr[i] = int.MaxValue;
                arr[i] = 0;
            }
            for (int i = 1; i < 40; i++)
                list.Add((long)Math.Pow(k, i));

        }

        //public void update(int p, int value)
        //{  // set value at position p
        //    for (arr[p += n] = value; p > 1; p >>= 1) arr[p >> 1] = Math.Min( arr[p] , arr[p ^ 1]);
        //}

        //public void update(int i, int value)
        //{
        //    i += n / 2;
        //    arr[i] = value;
        //    for (; i > 1; i >>= 1)
        //        arr[i >> 1] = Math.Min(arr[i], arr[i ^ 1]);
        //}

        public void update(long i, long x)
        {
            //i = (n / 2) + i - 1;
            i = n + i - 1;
            arr[i] = x;
            //if (list.Contains(x)) count++;

            while (i > 0)
            {
                i = (i - 1) / 2;
                //arr[i] = Math.Min(arr[(i * 2) + 1], arr[(i * 2) + 2]);
                long tmp = arr[(i * 2 + 1)] + arr[(i * 2) + 2];
                arr[i] = tmp;
                //if (list.Contains(tmp)) count++;

                //if (arr[i * 2 + 1] > arr[i * 2 + 2])
                //{
                //    arr[i] = arr[i * 2 + 1];
                //}
                //else
                //{
                //    arr[i] = arr[i * 2 + 2];
                //}
                //arr[i] = arr[i * 2 + 1] + arr[i * 2 + 2];

            }

        }

        //call : query(a,b, 0, 0, n)
        //public int query(int a, int b, int k, int l, int r)
        //{
        //    if (r <= a || b <= l) return int.MaxValue;
        //    if (a <= l && r <= b) return arr[k];

        //    //return Math.Min(query(a, b, (k * 2) + 1, l, (l + r) / 2), query(a, b, (k * 2) + 2, (l + r) / 2, r));

        //    var vl = query(a, b, (k * 2) + 1, l, (l + r) / 2);
        //    var vr = query(a, b, (k * 2) + 2, (l + r) / 2, r);

        //    //var vl = query(a, b, (k << 1) + 1, l, (l + r) / 2);
        //    //var vr = query(a, b, (k + 1) << 1, (l + r) / 2, r);

        //    if (vl == int.MaxValue && vr == int.MaxValue) return 0;
        //    return Math.Min(vl, vr);

        //}
        public int query()
        {
            for (int i = 0; i < arr.Length; i++)
            {
                long tmp = arr[i];
                if (!list.Contains(tmp)) continue;
                count++;

            }
            return count;
        }

        //public int query(int a, int b, int k, int l, int r)
        //{
        //    // query for arr[i..j]

        //    if (l > b || r < a)               // segment completely outside range
        //        return int.MaxValue;                       // represents a null node

        //    if (a <= l && b >= r)             // segment completely inside range
        //        return arr[k];

        //    int mid = l + (r - l) / 2;       // partial overlap of current segment and queried range. Recurse deeper.

        //    if (a > mid)
        //        return query(2 * k + 2, mid + 1, r, a, b);
        //    else if (b <= mid)
        //        return query(2 * k + 1, l, mid, a, b);

        //    int leftQuery = query(2 * k + 1, l, mid, a, mid);
        //    int rightQuery = query(2 * k + 2, mid + 1, r, mid + 1, b);

        //    // merge query results
        //    if (leftQuery == int.MaxValue && rightQuery == int.MaxValue) return 0;
        //    return Math.Min(leftQuery, rightQuery);

        //}

        //public int query(int l, int r)
        //{
        //    int res = int.MaxValue;
        //    for (l += n, r += n; l < r; l >>= 1, r >>= 1)
        //    {
        //        if ((l & 1) == 1) res = Math.Min(res, arr[l++]);
        //        if ((r & 1) == 1) res = Math.Min(res, arr[--r]);
        //    }
        //    return res;
        //}

        //public int query(int a, int b, int r)
        //{
        //    int res = int.MaxValue;
        //    for (a += r / 2, b += r / 2; a <= b; a = (a + 1) >> 1, b = (b - 1) >> 1)
        //    //for (; a <= b; a = (a + 1) >> 1, b = (b - 1) >> 1)
        //    {
        //        if ((a & 1) != 0)
        //            res = Math.Min(res, arr[a]);
        //        if ((b & 1) == 0)
        //            res = Math.Min(res, arr[b]);
        //    }
        //    return res;
        //}

        //public int query(int l, int r)
        //{  // sum on interval [l, r)
        //    int res = int.MaxValue;
        //    for (l += n, r += n; l < r; l >>= 1, r >>= 1)
        //    {
        //        if ((l & 1) == 1) res = Math.Min(res, arr[l++]);

        //        if ((r & 1) == 1) res = Math.Min(res, arr[--r]);
        //    }
        //    return res;
        //}

    }

    class UnionFind
    {
        public int[] path;
        public int[] size;

        //public int[] parent;
        //public int[] child;

        public UnionFind(int n)
        {
            path = new int[n + 1];
            size = new int[n + 1];
            //parent = new int[n];
            //child = new int[n];

            for (int i = 0; i < n + 1; i++)
            {
                path[i] = i;
                size[i] = 1;
                //parent[i] = i;
                //child[i] = i;
            }

        }

        private int root(int i)
        {
            while (i != path[i])
            {
                path[i] = path[path[i]];
                i = path[i];
            }
            return i;
        }

        public bool find(int p, int q)
        {
            if (p < 0 || q < 0) return false;
            return root(p) == root(q);
        }

        public int rt(int p)
        {
            return root(p);
        }

        public void unite(int p, int q)
        {
            if (p < 0 || q < 0) return;
            //if (p < 0)
            //{
            //    int a = root(p * -1);
            //    int b = root(q);
            //}
            //if (q < 0) q *= -1;

            int i = root(p);
            int j = root(q);
            if (i == j) return;

            if (size[i] > size[j])
            {

                int tmp = i;
                i = j;
                j = tmp;
            }
            size[j] += size[i];
            path[i] = j;

        }

    }
}


using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;

//(づ｡◕ o ◕｡)づ ★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
namespace ConsoleApplication1
{
    public class Program
    {
        private readonly IDictionary<string, int> dict = new Dictionary<string, int> {
            {"Tetrahedron", 4},
            {"Cube", 6},
            {"Octahedron", 8},
            {"Dodecahedron", 12},
            {"Icosahedron", 20}
        };

        public void GetAnswer(ConsoleWorker inp)
        {
            int n = inp.GetNumber(int.Parse);
            int count = 0;
            for (int i = 0; i < n; i++)
            {
                string s = inp.GetInputLine();
                count += dict[s];
            }
            Console.WriteLine(count);
        }

        public static void Main()
        {
            var inp = new ConsoleWorker();
            //inp.RedirectInput();
            new Program().GetAnswer(inp);
        }
    }

    public class ConsoleWorker
    {
        public Queue<string> _inputs;
        public void RedirectInput(string filepath = "../../Input/input.txt") { Console.SetIn(new StreamReader(filepath)); }
        public string GetInputLine() { return Console.ReadLine(); }
        public string GetNext() { if (_inputs == null) _inputs = new Queue<string>(GetInputLine().Split(' ')); return _inputs.Dequeue(); }
        internal T[] GetArray<T>(Func<string, T> parse) { return GetInputLine().Split(' ').Select(x => parse(x)).ToArray(); }
        internal T GetNumber<T>(Func<string, T> parse) { return parse(GetNext()); }

        internal int[][] GetIntMatrix(int n, int m)
        {
            int[][] a = new int[n][];
            for (int i = 0; i < n; i++)
                a[i] = GetArray(int.Parse);
            return a;
        }
    }
}


using System;

namespace Codeforces_785A
{
    class Program
    {
        static void Main(string[] args)
        {
            int c = 0;
            int n = Convert.ToInt32(Console.ReadLine());

            for(int i=0;i<n;i++)
            {
                string a = Console.ReadLine().ToLower();

                if (a == "tetrahedron")
                    c += 4;
                else if (a == "cube")
                    c += 6;
                else if (a == "octahedron")
                    c += 8;
                else if (a == "dodecahedron")
                    c += 12;
                else if (a == "icosahedron")
                    c += 20;
            }
            Console.WriteLine(c);

        }
    }
}


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

namespace first
{
	class MainClass
	{
        public static void Main(string[] args)
		{
            //var textReader = new StreamReader(@"D:\Projects\cpp\input.txt");
            //Console.SetIn(textReader);

            int n = Convert.ToInt32(Console.ReadLine());

            var f = new Dictionary<string, int>();
            f.Add("Tetrahedron", 4);
            f.Add("Cube", 6);
            f.Add("Octahedron", 8);
            f.Add("Dodecahedron", 12);
            f.Add("Icosahedron", 20);

            int res = 0;

            for (int i = 0; i < n; i++)
            {
                res += f[Console.ReadLine()];
            }

            Console.WriteLine(res);
            //Console.ReadKey();
		}
	}
}


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

namespace R404.Div2.A
{
    class Program
    {
        static void Main(string[] args)
        {
            Dictionary<string, int> dataSet = new Dictionary<string, int>();
            dataSet.Add("Tetrahedron", 4);
            dataSet.Add("Cube", 6);
            dataSet.Add("Octahedron", 8);
            dataSet.Add("Dodecahedron", 12);
            dataSet.Add("Icosahedron", 20);
            int n = int.Parse(Console.ReadLine());
            int finalResult = 0;
            for (int i = 0; i < n; i++)
            {
                finalResult += dataSet[Console.ReadLine()];
            }
            Console.WriteLine(finalResult);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Data;
using System.Diagnostics;

namespace testing
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = Convert.ToInt32(Console.ReadLine());
            string polyhedron = "";
            int b = 0;
            for (int i=0; i<a; i++)
            {
                polyhedron = Console.ReadLine();
                switch (polyhedron)
                {
                    case "Tetrahedron":
                        b += 4;
                        break;
                    case "Cube":
                        b += 6;
                        break;
                    case "Octahedron":
                        b += 8;
                        break;
                    case "Dodecahedron":
                        b += 12;
                        break;
                    case "Icosahedron":
                        b += 20;
                        break;
                    default:
                        break;
                }
            }
            Console.WriteLine(b);
        }
    }
}


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

namespace ConsoleApp8
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] s = new string[n];
            int u = 0;
            for (int i = 0; i < n; i++)
            {
                s[i] = Console.ReadLine();
                if (s[i]== "Tetrahedron")
                {
                    u += 4;
                    continue;
                }
                if (s[i]== "Cube")
                {
                    u += 6;
                    continue;
                }
                if (s[i]== "Octahedron")
                {
                    u += 8;
                    continue;
                }
                if (s[i]== "Dodecahedron")
                {
                    u += 12;
                    continue;
                }
                if (s[i]== "Icosahedron")
                {
                    u += 20;
                    continue;
                }

            }
            Console.WriteLine(u);
        }

    }
}


using System;
namespace ConsoleApplication
{
    public class Program
    {
        public static void Main(string[] args)
        {
            int len = Convert.ToInt32(Console.ReadLine());
            long sum = 0;
            while (len > 0)
            {
                switch(Console.ReadLine())
                {
                    case "Tetrahedron": sum += 4; break;
                    case "Cube": sum += 6; break;
                    case "Octahedron": sum += 8; break;
                    case "Dodecahedron": sum += 12; break;
                    case "Icosahedron": sum += 20; break;
                    default: sum += 0; break;
                }
                len--;
            }
            Console.Write(sum);
        }
    }
}


using System;
using System.Collections.Generic;

namespace ConsoleApplication17
{
    class Program
    {
        static void Main(string[] args)
        {
            Dictionary<string, int> slovarDictionary = new Dictionary<string, int>() { {"Tetrahedron", 4}, { "Cube",6 }, { "Octahedron", 8 }, { "Dodecahedron", 12 }, { "Icosahedron", 20 } };

            int n = Int32.Parse(Console.ReadLine());

            int result = 0;

            List<string> stringList = new List<string>();

            for (int i = 0; i < n; i++)
            {
                stringList.Add(Console.ReadLine());
            }

            foreach (var el in stringList)
            {
                result += slovarDictionary[el];
            }

            Console.WriteLine(result);

        }
    }
}


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

namespace ZadanieA
{
    class Program
    {
        static void Main(string[] args)
        {
            int count = 0;
            int n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                string a = Console.ReadLine();
                switch (a)
                {
                    case "Tetrahedron": count += 4; break;
                    case "Cube": count += 6; break;
                    case "Octahedron": count += 8; break;
                    case "Dodecahedron": count += 12; break;
                    case "Icosahedron": count += 20; break;
                }
            }
            Console.Write(count);
        }
    }
}


using System;
using System.Collections.Generic;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Dictionary<string, int> map = new Dictionary<string, int>();

            map.Add("Tetrahedron", 4);
            map.Add("Cube",6);
            map.Add("Octahedron", 8);
            map.Add("Dodecahedron", 12);
            map.Add("Icosahedron", 20);

            int n = int.Parse(Console.ReadLine());
            string s;
            int sum = 0;
            for(int i = 0; i < n; i++)
            {
                s = Console.ReadLine();
                sum += map[s];

            }

            Console.WriteLine(sum);
        }
    }
}


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

namespace polyhedrons
{
    class Program
    {
        static void Main(string[] args)
        {
            int count = int.Parse(Console.ReadLine());

            Dictionary<string, int> poly = new Dictionary<string, int>()
            {
            {"Tetrahedron", 4},
            {"Cube", 6},
            {"Octahedron", 8},
            {"Dodecahedron", 12},
            {"Icosahedron", 20}
            };

            int sum = 0;
            for (int i = 0; i < count; i++)
            {

                string data = Console.ReadLine();

                sum += poly[data];
            }

            Console.WriteLine(sum);
        }
    }
}


fun readInt() = readLine()!!.toInt()

fun main() {
    val n = readInt()
    var k = 0
    for (i in 0 until n) {
        val s = readLine()!!
        k += when (s) {
            "Icosahedron" -> 20
            "Dodecahedron" -> 12
            "Octahedron" -> 8
            "Cube" -> 6
            "Tetrahedron" -> 4
            else -> 0
        }
    }
    print(k)
}


fun main() {
    val count = readLine()!!.toInt()
    var faces = 0
    var input: String

    for (i in 1..count) {
        input = readLine()!!
        when (input) {
            "Tetrahedron" -> faces += 4
            "Cube" -> faces += 6
            "Octahedron" -> faces += 8
            "Dodecahedron" -> faces += 12
            "Icosahedron" -> faces += 20
        }
    }

    println(faces)
}


fun readLn() = readLine()!!
fun readInt() = readLn().toInt()
fun readDouble() = readLn().toDouble()
fun readLong() = readLn().toLong()
fun readStrings() = readLn().split(' ')
fun readInts() = readStrings().map { it.toInt() }
fun readDoubles() = readStrings().map { it.toDouble() }
fun readLongs() = readStrings().map { it.toLong() }

fun getFaceCount(s: String): Int {
    return when (s) {
        "Tetrahedron" -> 4
        "Cube" -> 6
        "Octahedron" -> 8
        "Dodecahedron" -> 12
        "Icosahedron" -> 20
        else -> 0
    }
}

fun main(args: Array<String>) {
    val n = readInt()

    var totalFaceCount = 0
    for (i in 1..n) {
        val s = readLn()
        totalFaceCount += getFaceCount(s)
    }
    println(totalFaceCount)
}


fun main(args: Array<String>) {
    println("Hello world")
    val amount = readLine()!!.toInt()
    var result = 0
    for (i in 0 until amount) {
        val currentFigure = readLine() as String
        result = countFaces(result, currentFigure)
    }
    println(result)
}

fun countFaces(prevResult: Int, figureName: String): Int {
    var result = prevResult
    result += when (figureName) {
        "Tetrahedron" -> 4
        "Cube" -> 6
        "Octahedron" -> 8
        "Dodecahedron" -> 12
        "Icosahedron" -> 20
        else -> 0
    }
    return result
}


fun main(args: Array<String>) {
    val amount = readLine()!!.toInt()
    var result = 0
    for (i in 0 until amount) {
        val currentFigure = readLine() as String
        result = countFaces(result, currentFigure)
    }
    println(result)
}

fun countFaces(prevResult: Int, figureName: String): Int {
    var result = prevResult
    result += when (figureName) {
        "Tetrahedron" -> 4
        "Cube" -> 6
        "Octahedron" -> 8
        "Dodecahedron" -> 12
        "Icosahedron" -> 20
        else -> 0
    }
    return result
}


import java.util.*

fun main() {
    val s = Scanner(System.`in`)

    val n = s.nextInt()
    var total = 0

    val map = mutableMapOf('T' to 4, 'C' to 6, 'O' to 8, 'D' to 12, 'I' to 20)

    for(i in 0 until n) {
        total += map[s.nextLine()[0]]!!
    }
    println(total)
}


import java.util.*

fun main() {
    val s = Scanner(System.`in`)

    val n = s.nextInt()
    s.nextLine()
    var total = 0

    val map = mutableMapOf('T' to 4, 'C' to 6, 'O' to 8, 'D' to 12, 'I' to 20)

    for(i in 0 until n) {
        total += map[s.nextLine()[0]]!!
    }
    println(total)
}


import java.io.*
import java.util.*

class ProblemIO(val rd: BufferedReader, val wr: PrintWriter) {
    companion object {
        fun console() = ProblemIO(BufferedReader(InputStreamReader(System.`in`)), PrintWriter(System.out))
        fun files(inputFilename: String, outputFilename: String) =
                ProblemIO(BufferedReader(FileReader(File(inputFilename))), PrintWriter(File(outputFilename)))
    }

    var tok = StringTokenizer("")

    fun close() { rd.close(); wr.close() }
    fun <T> print(v: T) = wr.print(v)
    fun <T> println(v: T) = wr.println(v)
    fun readToken(): String {
        while (!tok.hasMoreTokens()) tok = StringTokenizer(rd.readLine())
        return tok.nextToken()
    }
    fun readLine(): String {
        tok = StringTokenizer("")
        return rd.readLine()
    }
    fun readInt(): Int = readToken().toInt()
    fun readLong(): Long = readToken().toLong()
}

fun main(args: Array<String>) {
    Thread({ val io = ProblemIO.console(); solve(io); io.close() }).start()
}

fun solve(io: ProblemIO) {
    val n = io.readInt()
    var res = 0
    for (i in 1 .. n) {
        val s = io.readToken()
        res += when(s[0]) {
            'T' -> 4
            'C' -> 6
            'O' -> 8
            'D' -> 12
            'I' -> 20
            else -> 0
        }
    }
    io.println(res)
}


fun main() {
    val r = System.`in`.bufferedReader()
    val s = StringBuilder()
    var ans = 0
    repeat(r.readLine()!!.toInt()) {
        ans += when(r.readLine()!!){
            "Tetrahedron" -> 4
            "Cube" -> 6
            "Octahedron" -> 8
            "Dodecahedron" -> 12
            else -> 20
        }
    }
    println(ans)
}


fun main(args: Array<String>) {
  val n = readLine()!!.toInt()
  var ret = 0
  for(i in 1..n) {
    val obj = readLine()
    when(obj) {
      "Tetrahedron"  -> ret += 4
      "Cube"         -> ret += 6
      "Octahedron"   -> ret += 8
      "Dodecahedron" -> ret += 12
      "Icosahedron"  -> ret += 20
    }
  }
  println(ret)
}


fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var faces = 0
    for (index in 0 until n) {
        when (readLine()!!) {
            "Tetrahedron" -> faces += 4
            "Cube" -> faces += 6
            "Octahedron" -> faces += 8
            "Dodecahedron" -> faces += 12
            "Icosahedron" -> faces += 20
        }
    }

    println(faces)
}


fun main(args: Array<String>){
    val n = readLine()!!.toInt()
    var ans = 0
    for (i in 1..n){
        val str = readLine()!!
        when (str[0]){
            'T' -> ans += 4
            'C' -> ans += 6
            'O' -> ans += 8
            'D' -> ans += 12
            'I' -> ans += 20
        }
    }
    println(ans)
}


fun main(args: Array<String>) {
    var n:Int = (readLine()!!).toInt()
    var faces:Int = 0

    var counter:Int = 0
    while (counter < n) {
        var figure:String = readLine()!!
        if (figure == "Tetrahedron")
            faces += 4
        else if (figure == "Cube")
            faces += 6
        else if (figure == "Octahedron")
            faces += 8
        else if (figure == "Dodecahedron")
            faces += 12
        else if (figure == "Icosahedron")
            faces += 20

        counter++
    }
    println(faces)
}


fun main() {
    val n = readLine()!!.toInt()

    var count = 0
    for (i in 0 until n) {
        val str = readLine()!!

        if (str == "Tetrahedron")
            count += 4
        else if (str == "Cube")
            count += 6
        else if (str == "Octahedron")
            count += 8
        else if (str == "Dodecahedron")
            count += 12
        else
            count += 20
    }

    print(count)
}


import java.lang.StringBuilder

fun main() {
    val n = readInt()
    var sum = 0
    repeat(n) {
        val figure = Figures.valueOf(readLineNonNull())
        sum += figure.sidesCount
    }
    println(sum)
}

enum class Figures(val sidesCount: Int) {
    Tetrahedron(4),
    Cube(6),
    Octahedron(8),
    Dodecahedron(12),
    Icosahedron(20),
}

private fun readLineNonNull() = readLine()!! // string line
private fun readInt() = readLineNonNull().toInt() // single int
private fun readStrings() = readLineNonNull().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints


fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readInts() = readStrings().map { it.toInt() }
fun readLong() = readString().toLong()
fun readLongs() = readStrings().map { it.toLong() }
fun readDouble() = readString().toDouble()
fun readDoubles() = readStrings().map { it.toDouble() }

fun main() {
    val n = readInt()
    var res = 0
    for (i in 1..n) {
        val shape = readString()
        res += when (shape) {
            "Tetrahedron" -> 4
            "Cube" -> 6
            "Octahedron" -> 8
            "Dodecahedron" -> 12
            "Icosahedron" -> 20
            else -> 0
        }
    }
    print(res)
}


import java.util.Scanner
fun main(){
    var s = Scanner(System.`in`);
    var n = s.nextInt();
    var i =0
    while(n>=0){
        var l = s.nextLine();
        when (l){
            "Tetrahedron"->i+=4
            "Cube"->i+=6
            "Octahedron"->i+=8
            "Dodecahedron"->i+=12
            "Icosahedron"->i+=20
        }
        n--;
    }
    print(i)
}


class Program {
    companion object {
        @JvmStatic
        fun main(args: Array<String>) {
            val size = readLine()!!.toInt()
            var sum = 0
            for (i in 1..size) {
               sum += when(readLine()!!.toString()){
                    "Tetrahedron" -> 4
                    "Cube" -> 6
                    "Octahedron" -> 8
                    "Dodecahedron" -> 12
                    "Icosahedron" -> 20
                    else -> 0
                }
            }
            println(sum)
        }
    }
}


val map = mapOf(
        "Tetrahedron" to 4,
        "Cube" to 6,
        "Octahedron" to 8,
        "Dodecahedron" to 12,
        "Icosahedron" to 20
)

fun main() {
    val n = readLine()!!.toInt()
    val result = (1..n).map { map[readLine()]!! }.sum()
    println(result)
}


fun main() {
    val facesByName: Map<String, Int> = mapOf(
        "Tetrahedron" to 4,
        "Cube" to 6,
        "Octahedron" to 8,
        "Dodecahedron" to 12,
        "Icosahedron" to 20
    )
    val numberOfPol = readLine()!!.toInt()

    var sum = 0
    for (i in 1..numberOfPol) {
        val polName = readLine()!!
        sum += facesByName.get(polName)!!
    }
    println(sum)
}


fun main() {
    val count = Integer.parseInt(readLine()!!)
    var faces = 0

    for (i in 0 until count) {
        faces += when (readLine()!!) {
            "Tetrahedron" -> 4
            "Cube" -> 6
            "Octahedron" -> 8
            "Dodecahedron" -> 12
            "Icosahedron" -> 20
            else -> 0
        }
    }

    println(faces)
}


import java.io.PrintWriter
import kotlin.math.*

fun main() {
    io.apply {

        val x: Map<String, Int> = mapOf("Tetrahedron" to 4, "Cube" to 6, "Octahedron" to 8, "Dodecahedron" to 12,
        "Icosahedron" to 20)

        val ans = (0 until int).map { x[str()] ?: 0 }.sum()
        cout .. ans .. nl

    }.cout.flush()
}

// @formatter:off
private val io = object {
    private val `in` = System.`in`
    private fun ll(): Long {
        var x: Int; var q = false; var n = 0L; do x = `in`.read() while (x < 33); if (x == 45) { q = true; x = `in`.read() }
        do { n = n * 10 - x + 48; x = `in`.read() } while (x > 32); return if (q) n else -n
    }
    val int get() = ll().toInt(); val long get() = ll()
    fun ints(n: Int = int): IntArray { return IntArray(n) { int } }
    fun ints1(n: Int = int): IntArray { return IntArray(n) { int - 1 } }
    val cout = PrintWriter(System.out); val nl = "\n"
    private var buf = CharArray(32)
    private var bufSize = 32
    fun str(expect: Int = 32): String {
        var ix = 0
        var x: Int
        if (bufSize < expect)
            buf = CharArray(expect)
        do x = `in`.read() while (x < 33)
        do {
            if (ix == bufSize) { bufSize *= 2; buf = buf.copyOf(bufSize) }
            buf[ix++] = x.toChar()
            x = `in`.read()
        } while (x > 32)
        return java.lang.String.copyValueOf(buf, 0, ix)
    }
    operator fun PrintWriter.rangeTo(a: Int): PrintWriter { print(a); print(" "); return this }
    operator fun PrintWriter.rangeTo(a: Long): PrintWriter { print(a); print(" "); return this }
    operator fun PrintWriter.rangeTo(a: IntArray): PrintWriter { a.forEach { print(it); print(" ") }; return this }
    operator fun PrintWriter.rangeTo(a: String): PrintWriter { write(a); return this }
} // @formatter:on

/* ----------- */


fun main() {
    var n: Int = readLine()!!.toInt()
    var shapes: Array<Char> = arrayOf()

    for (i in 0 until n) {
        var sInput: Char = readLine()!![0]
        shapes += sInput
    }

    var sumFaces: Int = 0

    shapes.forEach {
        when(it) {
            'T' -> sumFaces += 4
            'C' -> sumFaces += 6
            'O' -> sumFaces += 8
            'D' -> sumFaces += 12
            'I' -> sumFaces += 20
        }
    }

    println(sumFaces)
}


fun main() {
    var n: Int = readLine()!!.toInt()
    var sumFaces: Int = 0

    for (i in 0 until n) {
        var sInput: Char = readLine()!![0]
        when (sInput) {
            'T' -> sumFaces += 4
            'C' -> sumFaces += 6
            'O' -> sumFaces += 8
            'D' -> sumFaces += 12
            'I' -> sumFaces += 20
        }
    }
    println(sumFaces)
}


fun main(args: Array<String>){
    var n = readLine()!!.toInt()
    var count = 0
    for (i in 0 until n){
        when (readLine()){
            "Tetrahedron" -> count+=4
            "Cube" -> count+=6
            "Octahedron" -> count+=8
            "Dodecahedron" -> count+=12
            "Icosahedron"  -> count+=20
        }
    }
    print(count)
}


fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var arr = emptyArray<String>()
    for (i in 1..n)
        arr += readLine()!!
    val mnogr = mapOf("Tetrahedron" to "4", "Cube" to "6", "Octahedron" to "8", "Dodecahedron" to "12",  "Icosahedron" to "20")
    //var (a, b) = readLine()!!.split(" ").map(String::toInt)
    println(arr.map {mnogr[it]!!.toInt()}.sum())

}


fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var arr = emptyArray<String>()
    for (i in 1..n)
        arr += readLine()!!
    val mnogr = mapOf("Tetrahedron" to 4, "Cube" to 6, "Octahedron" to 8, "Dodecahedron" to 12,  "Icosahedron" to 20)
    //var (a, b) = readLine()!!.split(" ").map(String::toInt)
    println(arr.sumBy { mnogr[it]!! })

}


fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var count = 0
    for (i in 1..n)
        when (readLine()!!) {
            "Tetrahedron" -> count += 4
            "Cube" -> count += 6
            "Octahedron" -> count += 8
            "Dodecahedron" -> count += 12
            "Icosahedron" -> count += 20
        }
    println(count)

}


import java.util.*

fun main(args: Array<String>) {

    var n :Int
    var input = Scanner(System.`in`)
    n = input.nextInt()
    var ans = 0

    var line = input.nextLine();

    while(n-->0) {
        var line = input.nextLine();
        if(line[0]=='O') {
            ans += 8
        } else if(line[0]=='I') {
            ans += 20
        } else if(line[0]=='C') {
            ans += 6
        } else if(line[0]=='T') {
            ans += 4
        } else if(line[0]=='D') {
            ans += 12
        }
    }

    print(ans)
}


import java.lang.StringBuilder

fun main() {

    var n = readLine()!!.toInt()
    var res = 0

    while (n > 0) {
        res += when (readLine()!!) {
            "Tetrahedron" -> 4
            "Cube" -> 6
            "Octahedron" -> 8
            "Dodecahedron" -> 12
            else -> 20
        }
        n--
    }

    print(res)
}


fun main() {
    val n = readInt()
    var result = 0
    repeat(n) {
        result += convert(readLine()!!)
    }
    println(result)
}

private fun convert(s: String): Int =
    when (s.first()) {
        'T' -> 4
        'C' -> 6
        'O' -> 8
        'D' -> 12
        else -> 20
    }

private fun readInt() = readLine()!!.toInt()


fun main(){
    val num = readLine()!!.toInt()
    print((1..num).fold(0, {a, _ -> a + noOfFaces(readLine()!!)}))
}
fun noOfFaces(shape: String) = when(shape){
    "Tetrahedron" -> 4
    "Cube" -> 6
    "Octahedron" -> 8
    "Dodecahedron" -> 12
    "Icosahedron" -> 20
    else -> 0
}


fun main() {
    val n = readLine()!!.toInt()
    var sum = 0
    for(i in 0 until n) {
        sum += POLYGON.valueOf(readLine()!!).sides
    }
    print(sum)
}

enum class POLYGON(val sides: Int) {
    Tetrahedron(4),
    Cube(6),
    Octahedron(8),
    Dodecahedron(12),
    Icosahedron(20)
}


import java.io.*
import java.util.*

private fun solve() {
    var n = readInt()
    var ans = 0;
    for (i in 1..n) {
        var s = readLn();
        ans += when (s) {
            "Tetrahedron" -> 4
            "Cube" -> 6
            "Octahedron" -> 8
            "Dodecahedron" -> 12
            else -> 20
        }
    }

    out.print(ans);
}

private fun readLn() = nextLine() // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readDouble() = readLn().toDouble() // single double
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints
private fun readLongs() = readStrings().map { it.toLong() } // list of longs
private fun readDoubles() = readStrings().map { it.toDouble() } // list of doubles

private var br: BufferedReader? = null

@Throws(IOException::class)
private fun nextLine(): String {
    return br!!.readLine()
}

@Throws(IOException::class)
fun main() {
    var input = System.`in`
    var output = System.out
    try {
        val f = File("input.txt")
        if (f.exists() && f.canRead()) {
            input = FileInputStream(f)
            output = PrintStream("output.txt")
        }
    } catch (ignored: Throwable) {
    }
    br = BufferedReader(InputStreamReader(input))
    out = PrintWriter(PrintWriter(output))
    solve()
    br!!.close()
    out.close()
}

class Node constructor(var key: Int) {
    var prior: Int = 0
    var cnt: Int = 0
    var pushing: Boolean = false
    var left: Node? = null
    var right: Node? = null

    init {
        this.prior = rnd.nextInt()
        right = null
        left = right
        this.cnt = 1
        this.pushing = false
    }
}

private var out: PrintWriter = PrintWriter(System.out);

private val rnd = Random()

fun getCnt(t: Node?): Int {
    return t?.cnt ?: 0
}

fun update(t: Node?) {
    if (t != null) {
        t.cnt = 1 + getCnt(t.left) + getCnt(t.right)
    }
}

fun push(t: Node?) {
    if (t != null && t.pushing) {

        t.pushing = false
    }
}

fun pushAll(t: Node?) {
    if (t != null) {
        push(t)
        if (t.left != null) {
            pushAll(t.left)
        }
        if (t.right != null) {
            pushAll(t.right)
        }
    }
}

// [0,K),[K,N)
fun split(t: Node?, key: Int): Pair<Node?, Node?> {
    if (t == null) return Pair(null, null)
    push(t)
    if (key > t.key) {
        val p = split(t.right, key)
        t.right = p.first
        update(t)
        return Pair(t, p.second)
    } else {
        val p = split(t.left, key)
        t.left = p.second
        update(t)
        return Pair(p.first, t)
    }
}

//SPLIT ПО НЕЯВНОМУ КЛЮЧУ
// [0,K),[K,N)
fun split(t: Node?, key: Int, add: Int = 0): Pair<Node?, Node?> {
    if (t == null) return Pair(null, null);
    push(t)
    val curKey = add + getCnt(t.left)
    if (key > curKey) { //идем в правое поддерево
        val p = split(t.right, key, curKey + 1)
        t.right = p.first
        update(t)
        return Pair(t, p.second)
    } else { //идем в левое поддерево
        val p = split(t.left, key, add)
        t.left = p.second
        update(t)
        return Pair(p.first, t)
    }
}

//Все ключи в первом дереве должны быть меньше ключей во втором
fun merge(t1: Node?, t2: Node?): Node? {
    push(t1)
    push(t2)
    if (t1 == null) return t2
    if (t2 == null) return t1
    if (t1.prior > t2.prior) {
        t1.right = merge(t1.right, t2)
        update(t1)
        return t1
    } else {
        t2.left = merge(t1, t2.left)
        update(t2)
        return t2
    }
}

fun insert(t: Node?, newNode: Node): Node? {
    var t = t
    push(t)
    if (t == null) {
        t = newNode
    } else {
        val p = split(t, newNode.key, 0)
        t = merge(p.first, newNode)
        t = merge(t, p.second)
    }
    update(t)
    return t
}

//Объединяет 2 разных дерева
fun unite(t1: Node?, t2: Node?): Node? {
    var t1 = t1
    var t2 = t2
    if (t1 == null) return t2
    if (t2 == null) return t1
    push(t1)
    push(t2)
    if (t1.prior < t2.prior) {
        val c = t1
        t1 = t2
        t2 = c
    }
    val split1 = split(t2, t1.key)
    t1.left = unite(t1.left, split1.first)
    t1.right = unite(t1.right, split1.second)
    return t1
}

fun remove(t: Node?, key: Int): Node? {
    var t: Node? = t ?: return null
    if (t!!.key == key) {
        t = merge(t.left, t.right)
    } else {
        if (key < t.key) {
            t.left = remove(t.left, key)
        } else {
            t.right = remove(t.right, key)
        }
    }
    update(t)
    return t
}

fun find(t: Node?, key: Int): Node? {
    push(t)
    if (t == null) return null
    if (t.key == key) return t
    return if (t.key < key) {
        find(t.right, key)
    } else {
        find(t.left, key)
    }
}

fun get(t: Node?, key: Int, add: Int = 0): Node? {
    push(t)
    if (t == null) return null
    val curKey = add + getCnt(t.left)
    if (curKey == key) return t
    return if (key > curKey) { //идем в правое поддерево
        get(t.right, key, curKey + 1)
    } else {
        get(t.left, key, add)
    }
}

/**
 * Вырезает отрезок от i до j и вставляет в позицию k нового массива
 * (при k = 0 вставляет вначало)
 *
 * @param t Корень дерева
 * @param i Начало отрезка (включительно)
 * @param j Конец отрезка (включительно)
 * @param k Позиция вставки
 * @return Новое дерево
 */
fun replaceSegment(t: Node, i: Int, j: Int, k: Int): Node? {
    //Вырезаем отрезок и склеиваем
    val split1 = split(t, i, 0)
    val split2 = split(split1.second, j - i + 1, 0)
    val merge1 = merge(split1.first, split2.second)
    val removedSegment = split2.first

    //      out.println("Array without removed:" + getString(merge1));
    //      out.println("Removed Segment:" + getString(removedSegment));

    //разделяем и вставляем
    val split3 = split(merge1, k, 0)
    val merge2 = merge(split3.first, removedSegment)

    return merge(merge2, split3.second)
}

fun getKeysString(t: Node?): StringBuilder {
    if (t == null) return StringBuilder()
    val ans = StringBuilder()
    if (t.left != null) ans.append(getKeysString(t.left))
    ans.append(t.key)
    ans.append(" ")
    if (t.right != null) ans.append(getKeysString(t.right))
    return ans
}


fun main() {
    var ans = 0
    val n = readLine()!!.toInt()
    repeat(n) {
        readLine()!!.let {
            ans += when (it) {
                "Tetrahedron" -> 4
                "Cube" -> 6
                "Octahedron" -> 8
                "Dodecahedron" -> 12
                "Icosahedron" -> 20
                else -> throw Exception()
            }
        }
    }
    println(ans)
}


import java.io.BufferedReader
import java.io.InputStreamReader

fun main() {
    val br = BufferedReader(InputStreamReader(System.`in`))
    val n = br.readLine().toInt()
    val polyhedrons = List(n){br.readLine()}
    println(
        polyhedrons.fold(0L){acc, p ->
            val fst = p.first()
            acc + if (fst == 'T') 4
                else if (fst == 'C') 6
                else if (fst == 'O') 8
                else if (fst == 'D') 12
                else 20
        }
    )
}


private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints

private fun solve(n: Int): Int {
    return (1..n).fold(0) { acc, _ ->
        acc + when (readLn()) {
            "Tetrahedron"  -> 4
            "Cube"         -> 6
            "Octahedron"   -> 8
            "Dodecahedron" -> 12
            "Icosahedron"  -> 20
            else -> 0
        }
    }
}

fun main() {
    val n = readInt()
    println(solve(n))
}


private fun readLn() = readLine()!!
private fun readInt() = readLn().toInt()
private fun readStrings() = readLn().split(" ")
private fun readInts() = readStrings().map { it.toInt() }

fun main(args: Array<String>) {
    val polyFaces: HashMap<String, Int> = hashMapOf(
            "Tetrahedron" to 4,
            "Cube" to 6,
            "Octahedron" to 8,
            "Dodecahedron" to 12,
            "Icosahedron" to 20
        )

    val numOfPoly = readInt()
    var result: Int = 0

    for(i in 1..numOfPoly) {
        val poly = readLn()
        result += polyFaces.getOrElse(poly, {0})
    }
    println(result)
}


/**
 * Problem Link: https://codeforces.com/problemset/problem/785/A
 * Difficulty:  600
 */
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var sum = 0
    for (i in 0 until n) {
        val s = readLine()!!
        sum += when (s) {
            "Tetrahedron" -> 4
            "Cube" -> 6
            "Octahedron" -> 8
            "Dodecahedron" -> 12
            "Icosahedron" -> 20
            else -> 0
        }
    }
    println(sum)
}


import java.util.*

fun main(args: Array<String>) {

    val sc = Scanner(System.`in`)

    val mn = IntArray(sc.nextInt(), {
        val inp = sc.next()
        if (inp.equals("Tetrahedron"))
            4
        else
            if (inp.equals("Cube"))
                6
            else
                if (inp.equals("Octahedron"))
                    8
                else
                    if (inp.equals("Dodecahedron"))
                        12
                    else
                        20
    } )
    print(mn.sum())

}


//package problem785A

fun main() {
    val numPolyhedrons = readLine()!!.toInt()

    var sum = 0
    for (i in 0 until numPolyhedrons) {
        val currentShape = readLine()!!

        sum += when (currentShape[0]) {
            'T' -> 4
            'C' -> 6
            'O' -> 8
            'D' -> 12
            else -> 20
        }
    }

    println(sum)
}


fun main(args: Array<String>) {
    val count = readLine()!!.toInt()

    var faces = 0;
    repeat(count) {
        faces += when(readLine()) {
            "Tetrahedron" -> 4
            "Cube" -> 6
            "Octahedron" -> 8
            "Dodecahedron" -> 12
            "Icosahedron" -> 20
            else -> 0
        }
    }

    println(faces)
}


import java.util.*

fun main() {
  val sc = Scanner(System.`in`)
  var n = sc.nextInt()
  val x = (0 until n).map { sc.next() }

  var m = mapOf(
      "Tetrahedron" to 4,
      "Cube" to 6,
      "Octahedron" to 8,
      "Dodecahedron" to 12,
      "Icosahedron" to 20)

  var r = 0
  x.map { r += m[it]!! }
  println(r)
}


fun readLn() = readLine()!! // string line
fun readInt() = readLn().toInt() // single int
fun readLong() = readLn().toLong() // single long
fun readDouble() = readLn().toDouble() // single double
fun readStrings() = readLn().split(" ") // list of strings
fun readInts() = readStrings().map { it.toInt() } // list of ints
fun readLongs() = readStrings().map { it.toLong() } // list of longs
fun readDoubles() = readStrings().map { it.toDouble() } // list of doubles

val m = mapOf(
    "Tetrahedron" to 4,
    "Cube" to 6,
    "Octahedron" to 8,
    "Dodecahedron" to 12,
    "Icosahedron" to 20)

fun main() {
    var t = readInt()
    var ans = 0
    while (t-- > 0) {
        var s = readLn()
        ans += m[s]!!
    }
    println(ans)
}


import java.util.*

fun main() {
  val sc = Scanner(System.`in`)
  var n = sc.nextInt()
  val x = (0 until n).map { sc.next() }

  var m = mapOf(
      "Tetrahedron" to 4,
      "Cube" to 6,
      "Octahedron" to 8,
      "Dodecahedron" to 12,
      "Icosahedron" to 20)

  var r = 0
  for(i in 0 until n) {
      r += m[x[i]]!!
  }
  println(r)
}


private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints

fun main(args: Array<String>) {
    var n = readInt()
    var res = 0
    for(i in 1..n)
    {
        var s = readLine()
        res += if (s == "Tetrahedron") 4
        else if (s == "Cube") 6
        else if (s == "Octahedron") 8
        else if (s == "Dodecahedron") 12
        else 20
    }
    println(res)
}


import java.io.BufferedReader
import java.io.InputStreamReader
import java.util.*

object input {
    val reader = BufferedReader(InputStreamReader(System.`in`))
    var tokenizer = StringTokenizer("")

    fun next(): String {
        while (!tokenizer.hasMoreTokens()) {
            val nextLine = reader.readLine() ?: throw IllegalStateException()
            tokenizer = StringTokenizer(nextLine)
        }
        return tokenizer.nextToken()
    }

    fun nextInt(): Int {
        return next().toInt()
    }
}

fun main(array: Array<String>) {
    var res: Long = 0
    for (i in 1..input.nextInt()) {
        when (input.next()) {
            "Tetrahedron" -> res += 4
            "Cube" -> res += 6
            "Octahedron" -> res += 8
            "Dodecahedron" -> res += 12
            else -> res += 20
        }
    }
    println(res)
}


fun main() {
    val faceNumMap = hashMapOf(
        "Tetrahedron" to 4,
        "Cube" to 6,
        "Octahedron" to 8,
        "Dodecahedron" to 12,
        "Icosahedron" to 20
    )

    val n = readLine()!!.toInt()
    var ans = 0;
    for (i in 1..n) {
        val s = readLine()!!
        ans += faceNumMap[s]!!
    }
    println(ans)
}


import java.util.Scanner

    fun main(args: Array<String>) {
        val sc = Scanner(System.`in`)
        val n = sc.nextInt()
        val a = arrayOfNulls<String>(n)
        var x = 0
        var y = 0
        var z = 0
        var d = 0
        var f = 0
        for (i in 0 until n) {
            a[i] = sc.next()
            if (a[i] == "Icosahedron") x += 20
            if (a[i] == "Cube") y += 6
            if (a[i] == "Tetrahedron") z += 4
            if (a[i] == "Dodecahedron") d += 12
            if (a[i] == "Octahedron") f += 8
        }
        println(x + y + z + d + f)
    }


fun main() {
    val values = mapOf(
        Pair("Tetrahedron", 4),
        Pair("Cube", 6),
        Pair("Octahedron", 8),
        Pair("Dodecahedron", 12),
        Pair("Icosahedron", 20)
    )
    val n = readLine()!!.toInt()
    var solution = 0
    for (i in 1..n) {
        solution += values[readLine()!!]!!
    }
    print(solution)
}


fun main() {
    val n = readLine()!!.toInt()
    var sum = 0
    for(i in 0 until n) {
        sum += POLYGON.valueOf(readLine()!!).sides
    }
    print(sum)
}

enum class POLYGON(val sides: Int) {
    Tetrahedron(4),
    Cube(6),
    Octahedron(8),
    Dodecahedron(12),
    Icosahedron(20)
}


//package Codeforces

fun main(args:Array<String>){
    val hmap = HashMap<String,Int>(5)
    hmap["Tetrahedron"] = 4
    hmap["Cube"] = 6
    hmap["Octahedron"] = 8
    hmap["Dodecahedron"] = 12
    hmap["Icosahedron"] = 20
    var t = readLine()!!.toInt()
    var sum = 0
    while(t-->0){
        sum += hmap[readLine()!!]!!
    }
    println(sum)

}


import java.io.BufferedReader
import java.util.*

class Solver {
    private val inp = FastInputReader()

    fun solve() {
        var count = 0
        for (i in 0..inp.readInt() - 1)
            count += when(inp.next()) {
                "Tetrahedron" -> 4
                "Cube" -> 6
                "Octahedron" -> 8
                "Dodecahedron" -> 12
                else -> 20
            }
        print(count)
    }

    private class FastInputReader {
        private val bufferedReader: BufferedReader
        private var stringTokenizer: StringTokenizer = StringTokenizer("")

        fun readLine(): String = bufferedReader.readLine()
        fun next(): String {
            while (!stringTokenizer.hasMoreTokens())
                stringTokenizer = StringTokenizer(readLine())
            return stringTokenizer.nextToken()
        }

        fun readInt(): Int = next().toInt()
        fun readLong(): Long = next().toLong()
        fun readDouble(): Double = next().toDouble()

        init {
            bufferedReader = System.`in`.bufferedReader()
        }
    }
}

fun main(args: Array<String>) {
    Solver().solve()
}


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.text.*;

public class cf271b {

    static BufferedReader br;
    static Scanner sc;
    static PrintWriter out;

    public static void initA() {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            //br = new BufferedReader(new FileReader("input.txt"));
            sc = new Scanner(System.in);
            //out = new PrintWriter("output.txt");
            out = new PrintWriter(System.out);
        } catch (Exception e) {
        }
    }

    public static void initB() {
        try {

            br = new BufferedReader(new FileReader("input.txt"));
            sc = new Scanner(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");

        } catch (Exception e) {
        }
    }

    public static String getString() {
        try {
            return br.readLine();
        } catch (Exception e) {
        }
        return "";
    }

    public static Integer getInt() {
        try {
            return Integer.parseInt(br.readLine());
        } catch (Exception e) {
        }
        return 0;
    }

    public static Integer[] getIntArr() {
        try {
            StringTokenizer temp = new StringTokenizer(br.readLine());
            int n = temp.countTokens();
            Integer temp2[] = new Integer[n];
            for (int i = 0; i < n; i++) {
                temp2[i] = Integer.parseInt(temp.nextToken());
            }
            return temp2;
        } catch (Exception e) {
        }
        return null;
    }

    public static Long[] getLongArr() {
        try {
            StringTokenizer temp = new StringTokenizer(br.readLine());
            int n = temp.countTokens();
            Long temp2[] = new Long[n];
            for (int i = 0; i < n; i++) {
                temp2[i] = Long.parseLong(temp.nextToken());
            }
            return temp2;
        } catch (Exception e) {
        }
        return null;
    }

    public static String[] getStringArr() {
        try {
            StringTokenizer temp = new StringTokenizer(br.readLine());
            int n = temp.countTokens();
            String temp2[] = new String[n];
            for (int i = 0; i < n; i++) {
                temp2[i] = (temp.nextToken());
            }
            return temp2;
        } catch (Exception e) {
        }
        return null;
    }

    public static int getMax(Integer[] ar) {
        int t = ar[0];
        for (int i = 0; i < ar.length; i++) {
            if (ar[i] > t) {
                t = ar[i];
            }
        }
        return t;
    }

    public static void print(Object a) {
        out.println(a);
    }

    public static int nextInt() {
        return sc.nextInt();
    }

    public static double nextDouble() {
        return sc.nextDouble();
    }

    public static void main(String[] ar) {
        initA();
        solve();
        out.flush();
    }

    public static void solve() {
        int max = 100000;
        boolean notprime[] = new boolean[100000];

        for (int i = 2; i < max; i++) {
            for (int j = 2; j * i < max; j++) {
                notprime[i * j] = true;
            }
        }
        ArrayList<Integer> prime = new ArrayList<Integer>(100000);
        for (int i = 2; i < 100000; i++) {
            if (!notprime[i]) {
                prime.add(i);
            }
        }
        final int last = prime.size();

        Integer x[] = getIntArr();
        int n = x[0], m = x[1];
        int min[][] = new int[n][m];

        for (int i = 0; i < n; i++) {
            Integer temp[] = getIntArr();
            for (int ii = 0; ii < m; ii++) {
                int num = temp[ii];
                for (int p : prime) {
                    if (p >= num) {
                        num = p - num;
                        break;
                    }
                }
                min[i][ii] = num;

            }
        }

        int out = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            int sum = 0;
            for (int ii = 0; ii < m; ii++) {
                sum += min[i][ii];
            }
            out = Math.min(sum, out);

        }

        for (int i = 0; i < m; i++) {
            int sum = 0;
            for (int ii = 0; ii < n; ii++) {
                sum += min[ii][i];
            }
            out = Math.min(sum, out);

        }
        print(out);

    }
}


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.text.*;

public class cf271b {

    static BufferedReader br;
    static Scanner sc;
    static PrintWriter out;

    public static void initA() {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            //br = new BufferedReader(new FileReader("input.txt"));
            sc = new Scanner(System.in);
            //out = new PrintWriter("output.txt");
            out = new PrintWriter(System.out);
        } catch (Exception e) {
        }
    }

    public static void initB() {
        try {

            br = new BufferedReader(new FileReader("input.txt"));
            sc = new Scanner(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");

        } catch (Exception e) {
        }
    }

    public static String getString() {
        try {
            return br.readLine();
        } catch (Exception e) {
        }
        return "";
    }

    public static Integer getInt() {
        try {
            return Integer.parseInt(br.readLine());
        } catch (Exception e) {
        }
        return 0;
    }

    public static Integer[] getIntArr() {
        try {
            StringTokenizer temp = new StringTokenizer(br.readLine());
            int n = temp.countTokens();
            Integer temp2[] = new Integer[n];
            for (int i = 0; i < n; i++) {
                temp2[i] = Integer.parseInt(temp.nextToken());
            }
            return temp2;
        } catch (Exception e) {
        }
        return null;
    }

    public static Long[] getLongArr() {
        try {
            StringTokenizer temp = new StringTokenizer(br.readLine());
            int n = temp.countTokens();
            Long temp2[] = new Long[n];
            for (int i = 0; i < n; i++) {
                temp2[i] = Long.parseLong(temp.nextToken());
            }
            return temp2;
        } catch (Exception e) {
        }
        return null;
    }

    public static String[] getStringArr() {
        try {
            StringTokenizer temp = new StringTokenizer(br.readLine());
            int n = temp.countTokens();
            String temp2[] = new String[n];
            for (int i = 0; i < n; i++) {
                temp2[i] = (temp.nextToken());
            }
            return temp2;
        } catch (Exception e) {
        }
        return null;
    }

    public static int getMax(Integer[] ar) {
        int t = ar[0];
        for (int i = 0; i < ar.length; i++) {
            if (ar[i] > t) {
                t = ar[i];
            }
        }
        return t;
    }

    public static void print(Object a) {
        out.println(a);
    }

    public static int nextInt() {
        return sc.nextInt();
    }

    public static double nextDouble() {
        return sc.nextDouble();
    }

    public static void main(String[] ar) {
        initA();
        solve();
        out.flush();
    }

    public static void solve() {
        /*
        int max = 100000;
        boolean notprime[] = new boolean[100000];

        for (int i = 2; i < max; i++) {
        for (int j = 2; j * i < max; j++) {
        notprime[i * j] = true;
        }
        }
        ArrayList<Integer> prime = new ArrayList<Integer>(100000);
        for (int i = 2; i < 100000; i++) {
        if (!notprime[i]) {
        prime.add(i);
        }
        }
        final int last = prime.size();
         *
         */

        Integer x[] = getIntArr();
        int n = x[0], m = x[1];
        int min[][] = new int[n][m];

        for (int i = 0; i < n; i++) {
            Integer temp[] = getIntArr();
            for (int ii = 0; ii < m; ii++) {
                int num = temp[ii];
                int s =0;
                while (!isPrime(num)) {
                    num++;
                    s++;
                }
                min[i][ii] = s;

            }
        }

        int out = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            int sum = 0;
            for (int ii = 0; ii < m; ii++) {
                sum += min[i][ii];
            }
            out = Math.min(sum, out);

        }

        for (int i = 0; i < m; i++) {
            int sum = 0;
            for (int ii = 0; ii < n; ii++) {
                sum += min[ii][i];
            }
            out = Math.min(sum, out);

        }
        print(out);

    }

    static boolean isPrime(int n) {
        if (n == 2 || n == 3) {
            return true;
        }
        if (n < 2 || n % 2 == 0) {
            return false;
        }
        for (int i = 3; i <= Math.sqrt(n) + 1; i += 2) {
            if (n % i == 0) {
                return false;
            }
        }
        return true;

    }
}