var signalPassanger = 'S';
var separator = '-';
var commonPassanger = 'P';
var newPassanger = 'x';
var freePlace = '.';

var firstLine = readline().split(' ').map(function(v){return +v;});
var rowsCount = +firstLine[0];
var rows = [];
var passangerCount = +firstLine[1];

for (var i = 0; i < rowsCount; i++) {
    rows.push(readline());
}

function replaceAt(string, index, replace) {
  return string.substring(0, index) + replace + string.substring(index + 1);
}

function calcWeight(string, index) {
    var result = 0;
    switch (index) {
        case 0: case 4: case 9:
            if (string.charAt(index + 1) == signalPassanger) result++;
            break;
        case 2: case 7: case 11:
            if (string.charAt(index - 1) == signalPassanger) result++;
            break;
        default:
            if (string.charAt(index - 1) == signalPassanger) result++;
            if (string.charAt(index + 1) == signalPassanger) result++;
    }

    return result;
}

function arrangePassangers(weight) {
    if (passangerCount === 0) return;

    for (var i = 0; i < rowsCount; i++) {
        for (var j = 0; j < 12; j++) {
            if (rows[i].charAt(j) == freePlace) {
                if ((calcWeight(rows[i], j) === weight) && (passangerCount > 0)) {
                    rows[i] = replaceAt(rows[i], j, newPassanger);
                    passangerCount--;
                }
            }
        }
    }
}

function isPassanger(string, index) {
    return (string.charAt(index) != freePlace);
}

arrangePassangers(0);
arrangePassangers(1);
arrangePassangers(2);

var result = 0;
var currentChar = '';

for (var i = 0; i < rowsCount; i++) {
    for (var j = 0; j < 12; j++) {
        if (rows[i].charAt(j) == signalPassanger) {
            switch (j) {
                case 0: case 4: case 9:
                    if (isPassanger(rows[i], j + 1)) result++;
                    break;
                case 2: case 7: case 11:
                    if (isPassanger(rows[i], j - 1)) result++;
                    break;
                default:
                    if (isPassanger(rows[i], j - 1)) result++;
                    if (isPassanger(rows[i], j + 1)) result++;
            }
        }
    }
}

print(result);

for (var i = 0; i < rowsCount; i++) {
    print(rows[i])
}

var first = readline().split(' ');
	var rows_count = +first[0];
	var people = +first[1];
	var matrix = [];
	var zero = 0;
	var one = 0;
	var two = 0;
	var return_val = 0;
	var dif_val = 0;
	for (var inc1=0; inc1<rows_count; inc1++)
	{
		matrix[inc1] = readline();
		if ((matrix[inc1][0] == 'S')&&(matrix[inc1][1] != '.')) return_val++;
		if ((matrix[inc1][11] == 'S')&&(matrix[inc1][10] != '.')) return_val++;
		if (matrix[inc1][0] == '.')
		{
			if (matrix[inc1][1] == 'S') one++;
			else zero++;
		}
		if (matrix[inc1][11] == '.')
		{
			if (matrix[inc1][10] == 'S') one++;
			else zero++;
		}
		for (var inc2=1; inc2<11; inc2++)
		{
			if ((matrix[inc1][inc2] == 'S')&&(matrix[inc1][inc2-1] != '.')&&(matrix[inc1][inc2-1] != '-')) return_val++;
			if ((matrix[inc1][inc2] == 'S')&&(matrix[inc1][inc2+1] != '.')&&(matrix[inc1][inc2+1] != '-')) return_val++;
			if (matrix[inc1][inc2] == '.')
			{
				if ((matrix[inc1][inc2-1] == 'S')&&(matrix[inc1][inc2+1] == 'S')) two++;
				else if ((matrix[inc1][inc2-1] != 'S')&&(matrix[inc1][inc2+1] != 'S')) zero++;
				else one++;
			}
		}
	}
	if (people > zero + one ) dif_val = 2;
	else if (people > zero ) dif_val = 1;
	if (dif_val == 1)
		{
			return_val = return_val + ( people - zero );
			people = people - zero;
		}
	if (dif_val == 2)
		{
			return_val = return_val + one + ( people - zero - one )*2;
			people = people - zero - one;
		}

	print(return_val);

	for (var inc1=0; inc1<rows_count; inc1++)
	{
		if ((matrix[inc1][0] == '.')&&(matrix[inc1][1] != 'S')&&(dif_val == 0)&&(people > 0))
		{
			matrix[inc1] = 'x' + matrix[inc1].substr(1);
			people--;
		}
		if ((matrix[inc1][0] == '.')&&(matrix[inc1][1] != 'S')&&(dif_val > 0))
		{
			matrix[inc1] = 'x' + matrix[inc1].substr(1);
		}
		if ((matrix[inc1][0] == '.')&&(matrix[inc1][1] == 'S')&&(dif_val == 1)&&(people > 0))
		{
			matrix[inc1] = 'x' + matrix[inc1].substr(1);
			people--;
		}
		if ((matrix[inc1][0] == '.')&&(matrix[inc1][1] == 'S')&&(dif_val > 1))
		{
			matrix[inc1] = 'x' + matrix[inc1].substr(1);
		}
		if ((matrix[inc1][11] == '.')&&(matrix[inc1][10] != 'S')&&(dif_val == 0)&&(people > 0))
		{
			matrix[inc1] = matrix[inc1].substr(0, 11) + 'x';
			people--;
		}
		if ((matrix[inc1][11] == '.')&&(matrix[inc1][10] != 'S')&&(dif_val > 0))
		{
			matrix[inc1] = matrix[inc1].substr(0, 11) + 'x';
		}
		if ((matrix[inc1][11] == '.')&&(matrix[inc1][10] == 'S')&&(dif_val == 1)&&(people > 0))
		{
			matrix[inc1] = matrix[inc1].substr(0, 11) + 'x';
			people--;
		}
		if ((matrix[inc1][11] == '.')&&(matrix[inc1][10] == 'S')&&(dif_val > 1))
		{
			matrix[inc1] = matrix[inc1].substr(0, 11) + 'x';
		}
		for (var inc2=1; inc2<11; inc2++)
		{
			if ((matrix[inc1][inc2] == '.')&&(dif_val == 2))
			{
				if ((matrix[inc1][inc2-1] == 'S')&&(matrix[inc1][inc2+1] == 'S'))
				{
					if (people > 0)
					{
					matrix[inc1] = matrix[inc1].substr(0, inc2) + 'x' + matrix[inc1].substr(inc2 + 1);
					people--;
					}
				}
				else matrix[inc1] = matrix[inc1].substr(0, inc2) + 'x' + matrix[inc1].substr(inc2 + 1);
			}
			if ((matrix[inc1][inc2] == '.')&&(dif_val == 0)&&(people > 0))
			{
				if ((matrix[inc1][inc2-1] != 'S')&&(matrix[inc1][inc2+1] != 'S'))
				{
					matrix[inc1] = matrix[inc1].substr(0, inc2) + 'x' + matrix[inc1].substr(inc2 + 1);
					people--;
				}
			}
			if ((matrix[inc1][inc2] == '.')&&(dif_val == 1))
			{
				if ((matrix[inc1][inc2-1] == 'S')&&(matrix[inc1][inc2+1] == 'S')) {}
				else if ((matrix[inc1][inc2-1] != 'S')&&(matrix[inc1][inc2+1] != 'S'))
					matrix[inc1] = matrix[inc1].substr(0, inc2) + 'x' + matrix[inc1].substr(inc2 + 1);
				else if (people > 0)
				{
					matrix[inc1] = matrix[inc1].substr(0, inc2) + 'x' + matrix[inc1].substr(inc2 + 1);
					people--;
				}
			}
		}
		print(matrix[inc1]);
	}

var numbers = readline().split(" ").map(function(x) { return parseInt(x); });
var N = numbers[0];
var K = numbers[1];

var lines = [];
var indexWith0Score = [];
var indexWith1Score = [];
var indexWith2Score = [];
var score = 0;

for(var i = 0; i < N; i++) {
    var newLine = readline();
    lines.push(newLine.split(''));
    for(var k = 0; k < newLine.length; k++) {
        var position = {row: i, col: k};
        if(newLine[k] === '.') {
            if(k === 0) {
                if(newLine[k + 1] === 'S') {
                    indexWith1Score.push(position);
                } else {
                    indexWith0Score.push(position);
                }
            } else if(k === newLine[newLine.length - 1]) {
                if(newLine[k - 1] === 'S') {
                    indexWith1Score.push(position);
                } else {
                    indexWith0Score.push(position);
                }
            } else {
                if(newLine[k + 1] === 'S' && newLine[k - 1] === 'S') {
                    indexWith2Score.push(position);
                } else if(newLine[k + 1] === 'S' || newLine[k - 1] === 'S') {
                    indexWith1Score.push(position);
                } else {
                    indexWith0Score.push(position);
                }
            }
        } else if(newLine[k] === 'S') {
            if(newLine[k + 1] === 'P' || newLine[k + 1] === 'S') {
                score++;
            }
            if(newLine[k - 1] === 'P' || newLine[k - 1] === 'S' ) {
                score++;
            }
        }
    }
}

var placedPassangers = 0;

for(var i = 0; i < indexWith0Score.length; i++) {
    if(placedPassangers >= K) break;
    var position = indexWith0Score[i];
    lines[position.row][position.col] = 'x';
    placedPassangers++;
}

for(var i = 0; i < indexWith1Score.length; i++) {
    if(placedPassangers >= K) break;
    var position = indexWith1Score[i];
    lines[position.row][position.col] = 'x';
    score++;
    placedPassangers++;
}

for(var i = 0; i < indexWith2Score.length; i++) {
    if(placedPassangers >= K) break;
    var position = indexWith2Score[i];
    lines[position.row][position.col] = 'x';
    score+=2;
    placedPassangers++;
}

write(score + '\n' + lines.map(function(item) {return item.join('')}).join('\n'));

'use strict'
let config = readline()
function getPlaneData(){
    let x = readline()
	let i=x;
    while(typeof x != 'undefined'){
		x=readline()
		if(x){
			i+='-'+x
		}
    }
    return i
}

let inputs = getPlaneData()
let passengers = parseInt(config.split(" ")[1])
let none = []
let one = []
let two = []
let nb = 0
function parser(s){
	for(let i=0,l=s.length;i<l;i++){
		if(s[i]=='.'){
			let enbrs = 0//elite neigbours
			if(s[i-1] == 'S'){
				enbrs++
			}
			if(s[i+1] == 'S'){
				enbrs++
			}
			switch(enbrs){
				case 0:
					none.push(i)
				break
				case 1:
					one.push(i)
				break
				case 2:
					two.push(i)
				break
			}
		}
		if(s[i]=='S'){
			if(s[i-1]){
				if(s[i-1] != '-' && s[i-1] != '.'){
					nb++
				}
			}
			if(s[i+1]){
				if(s[i+1] != '-' && s[i+1] != '.'){
					nb++
				}
			}
		}
	}
	let strarr = s.split('')
	let x = 'x'
	while(passengers!=0){
		if(none.length!=0){
			strarr[none.shift()] = x
		} else if(one.length!=0){
			strarr[one.shift()] = x
			nb+=1
		} else {
			strarr[two.shift()] = x
			nb+=2
		}
		passengers--;
	}
	print(nb)
	let m = strarr.join('').match(/.{1,12}./g)
	for(let out of m){
		if(out.length==13){
			print(out.slice(0,-1))
		} else{
			print(out)
		}
	}
}
parser(inputs)

var signalPassanger = 'S';
var separator = '-';
var commonPassanger = 'P';
var newPassanger = 'x';
var freePlace = '.';

var firstLine = readline().split(' ').map(function(v){return +v;});
var rowsCount = +firstLine[0];
var rows = [];
var passangerCount = +firstLine[1];

for (var i = 0; i < rowsCount; i++) {
    rows.push(readline());
}

function replaceAt(string, index, replace) {
  return string.substring(0, index) + replace + string.substring(index + 1);
}

function calcWeight(string, index) {
    var result = 0;
    switch (index) {
        case 0: case 4: case 9:
            if (string.charAt(index + 1) == signalPassanger) result++;
            break;
        case 2: case 7: case 11:
            if (string.charAt(index - 1) == signalPassanger) result++;
            break;
        default:
            if (string.charAt(index - 1) == signalPassanger) result++;
            if (string.charAt(index + 1) == signalPassanger) result++;
    }

    return result;
}

function arrangePassangers(weight) {
    if (passangerCount === 0) return;

    for (var i = 0; i < rowsCount; i++) {
        for (var j = 0; j < 12; j++) {
            if (rows[i].charAt(j) == freePlace) {
                if ((calcWeight(rows[i], j) === weight) && (passangerCount > 0)) {
                    rows[i] = replaceAt(rows[i], j, newPassanger);
                    passangerCount--;
                }
            }
        }
    }
}

function isPassanger(string, index) {
    return (string.charAt(index) == commonPassanger) ||
            (string.charAt(index) == newPassanger);
}

arrangePassangers(0);
arrangePassangers(1);
arrangePassangers(2);

var result = 0;
var currentChar = '';

for (var i = 0; i < rowsCount; i++) {
    for (var j = 0; j < 12; j++) {
        if (rows[i].charAt(j) == signalPassanger) {
            switch (j) {
                case 0: case 4: case 9:
                    if (isPassanger(rows[i], j + 1)) result++;
                    break;
                case 2: case 7: case 11:
                    if (isPassanger(rows[i], j - 1)) result++;
                    break;
                default:
                    if (isPassanger(rows[i], j - 1)) result++;
                    if (isPassanger(rows[i], j + 1)) result++;
            }
        }
    }
}

print(result + 2);

for (var i = 0; i < rowsCount; i++) {
    print(rows[i]);
}

var first = readline().split(' ');
	var rows_count = +first[0];
	var people = +first[1];
	var matrix = [];
	var zero = 0;
	var one = 0;
	var two = 0;
	var return_val = 0;
	var dif_val = 0;
	for (var inc1=0; inc1<rows_count; inc1++)
	{
		matrix[inc1] = readline();
		if ((matrix[inc1][0] == 'S')&&(matrix[inc1][1] != '.')) return_val++;
		if ((matrix[inc1][11] == 'S')&&(matrix[inc1][10] != '.')) return_val++;
		if (matrix[inc1][0] == '.')
		{
			if (matrix[inc1][1] == 'S') one++;
			else zero++;
		}
		if (matrix[inc1][11] == '.')
		{
			if (matrix[inc1][10] == 'S') one++;
			else zero++;
		}
		for (var inc2=1; inc2<11; inc2++)
		{
			if ((matrix[inc1][inc2] == 'S')&&(matrix[inc1][inc2-1] != '.')&&(matrix[inc1][inc2-1] != '-')) return_val++;
			if ((matrix[inc1][inc2] == 'S')&&(matrix[inc1][inc2+1] != '.')&&(matrix[inc1][inc2+1] != '-')) return_val++;
			if (matrix[inc1][inc2] == '.')
			{
				if ((matrix[inc1][inc2-1] == 'S')&&(matrix[inc1][inc2+1] == 'S')) two++;
				else if ((matrix[inc1][inc2-1] != 'S')&&(matrix[inc1][inc2+1] != 'S')) zero++;
				else one++;
			}
		}
	}
	if (people > zero + one ) dif_val = 2;
	else if (people > zero ) dif_val = 1;
	if (dif_val == 1)
		{
			return_val = return_val + ( people - zero );
			people = people - zero;
		}
	if (dif_val == 2)
		{
			return_val = return_val + one + ( people - zero - one )*2;
			people = people - zero - one;
		}

	print(return_val);

	for (var inc1=0; inc1<rows_count; inc1++)
	{
		if ((matrix[inc1][0] == '.')&&(matrix[inc1][1] != 'S')&&(dif_val == 0)&&(people > 0))
		{
			matrix[inc1] = 'x' + matrix[inc1].substr(1);
			//matrix[inc1][0] = 'x';
			people--;
		}
		if ((matrix[inc1][0] == '.')&&(matrix[inc1][1] != 'S')&&(dif_val > 0))
		{
			matrix[inc1] = 'x' + matrix[inc1].substr(1);
		}
		if ((matrix[inc1][0] == '.')&&(matrix[inc1][1] == 'S')&&(dif_val == 1)&&(people > 0))
		{
			matrix[inc1] = 'x' + matrix[inc1].substr(1);
			people--;
		}
		if ((matrix[inc1][0] == '.')&&(matrix[inc1][1] == 'S')&&(dif_val > 1))
		{
			matrix[inc1] = 'x' + matrix[inc1].substr(1);
		}
		if ((matrix[inc1][11] == '.')&&(matrix[inc1][10] != 'S')&&(dif_val == 0)&&(people > 0))
		{
			matrix[inc1] = matrix[inc1].substr(0, 11) + 'x';
			people--;
		}
		if ((matrix[inc1][11] == '.')&&(matrix[inc1][10] != 'S')&&(dif_val > 0))
		{
			matrix[inc1] = matrix[inc1].substr(0, 11) + 'x';
		}
		if ((matrix[inc1][11] == '.')&&(matrix[inc1][10] == 'S')&&(dif_val == 1)&&(people > 0))
		{
			matrix[inc1] = matrix[inc1].substr(0, 11) + 'x';
			people--;
		}
		if ((matrix[inc1][11] == '.')&&(matrix[inc1][10] == 'S')&&(dif_val > 1))
		{
			matrix[inc1] = matrix[inc1].substr(0, 11) + 'x';
		}
		for (var inc2=1; inc2<11; inc2++)
		{
			if ((matrix[inc1][inc2] == '.')&&(dif_val == 2)&&(people > 0))
			{
				if ((matrix[inc1][inc2-1] == 'S')&&(matrix[inc1][inc2+1] == 'S'))
				{
					matrix[inc1] = matrix[inc1].substr(0, inc2) + 'x' + matrix[inc1].substr(inc2 + 1);
					people--;
				}
				else matrix[inc1] = matrix[inc1].substr(0, inc2) + 'x' + matrix[inc1].substr(inc2 + 1);
			}
			if ((matrix[inc1][inc2] == '.')&&(dif_val == 0)&&(people > 0))
			{
				if ((matrix[inc1][inc2-1] != 'S')&&(matrix[inc1][inc2+1] != 'S'))
				{
					matrix[inc1] = matrix[inc1].substr(0, inc2) + 'x' + matrix[inc1].substr(inc2 + 1);
					people--;
				}
			}
			if ((matrix[inc1][inc2] == '.')&&(dif_val == 1)&&(people > 0))
			{
				if ((matrix[inc1][inc2-1] == 'S')&&(matrix[inc1][inc2+1] == 'S')) {}
				else if ((matrix[inc1][inc2-1] != 'S')&&(matrix[inc1][inc2+1] != 'S'))
					matrix[inc1] = matrix[inc1].substr(0, inc2) + 'x' + matrix[inc1].substr(inc2 + 1);
				else
				{
					matrix[inc1] = matrix[inc1].substr(0, inc2) + 'x' + matrix[inc1].substr(inc2 + 1);
					people--;
				}
			}
		}
		print(matrix[inc1]);
	}

var first = readline().split(' ');
	var rows_count = +first[0];
	var people = +first[1];
	var matrix = [];
	var zero = 0;
	var one = 0;
	var two = 0;
	var return_val = 0;
	var dif_val = 0;
	for (var inc1=0; inc1<rows_count; inc1++)
	{
		matrix[inc1] = readline();
		if ((matrix[inc1][0] == 'S')&&(matrix[inc1][1] != '.')) return_val++;
		if ((matrix[inc1][11] == 'S')&&(matrix[inc1][10] != '.')) return_val++;
		if (matrix[inc1][0] == '.')
		{
			if (matrix[inc1][1] == 'S') one++;
			else zero++;
		}
		if (matrix[inc1][11] == '.')
		{
			if (matrix[inc1][10] == 'S') one++;
			else zero++;
		}
		for (var inc2=1; inc2<11; inc2++)
		{
			if ((matrix[inc1][inc2] == 'S')&&(matrix[inc1][inc2-1] != '.')&&(matrix[inc1][inc2-1] != '-')) return_val++;
			if ((matrix[inc1][inc2] == 'S')&&(matrix[inc1][inc2+1] != '.')&&(matrix[inc1][inc2+1] != '-')) return_val++;
			if (matrix[inc1][inc2] == '.')
			{
				if ((matrix[inc1][inc2-1] == 'S')&&(matrix[inc1][inc2+1] == 'S')) two++;
				else if ((matrix[inc1][inc2-1] != 'S')&&(matrix[inc1][inc2+1] != 'S')) zero++;
				else one++;
			}
		}
	}
	if (people > zero + one ) dif_val = 2;
	else if (people > zero ) dif_val = 1;
	if (dif_val == 1)
		{
			return_val = return_val + ( people - zero );
			people = people - zero;
		}
	if (dif_val == 2)
		{
			return_val = return_val + one + ( people - zero - one )*2;
			people = people - zero - one;
		}

	print(return_val);

	for (var inc1=0; inc1<rows_count; inc1++)
	{
		if ((matrix[inc1][0] == '.')&&(matrix[inc1][1] != 'S')&&(dif_val == 0)&&(people > 0))
		{
			matrix[inc1] = 'x' + matrix[inc1].substr(1);
			//matrix[inc1][0] = 'x';
			people--;
		}
		if ((matrix[inc1][0] == '.')&&(matrix[inc1][1] != 'S')&&(dif_val > 0))
		{
			matrix[inc1] = 'x' + matrix[inc1].substr(1);
		}
		if ((matrix[inc1][0] == '.')&&(matrix[inc1][1] == 'S')&&(dif_val == 1)&&(people > 0))
		{
			matrix[inc1] = 'x' + matrix[inc1].substr(1);
			people--;
		}
		if ((matrix[inc1][0] == '.')&&(matrix[inc1][1] == 'S')&&(dif_val > 1))
		{
			matrix[inc1] = 'x' + matrix[inc1].substr(1);
		}
		if ((matrix[inc1][11] == '.')&&(matrix[inc1][10] != 'S')&&(dif_val == 0)&&(people > 0))
		{
			matrix[inc1] = matrix[inc1].substr(0, 11) + 'x';
			people--;
		}
		if ((matrix[inc1][11] == '.')&&(matrix[inc1][10] != 'S')&&(dif_val > 0))
		{
			matrix[inc1] = matrix[inc1].substr(0, 11) + 'x';
		}
		if ((matrix[inc1][11] == '.')&&(matrix[inc1][10] == 'S')&&(dif_val == 1)&&(people > 0))
		{
			matrix[inc1] = matrix[inc1].substr(0, 11) + 'x';
			people--;
		}
		if ((matrix[inc1][11] == '.')&&(matrix[inc1][10] == 'S')&&(dif_val > 1))
		{
			matrix[inc1] = matrix[inc1].substr(0, 11) + 'x';
		}
		for (var inc2=1; inc2<11; inc2++)
		{
			if ((matrix[inc1][inc2] == '.')&&(dif_val == 2))
			{
				if ((matrix[inc1][inc2-1] == 'S')&&(matrix[inc1][inc2+1] == 'S')&&(people > 0))
				{
					matrix[inc1] = matrix[inc1].substr(0, inc2) + 'x' + matrix[inc1].substr(inc2 + 1);
					people--;
				}
				else matrix[inc1] = matrix[inc1].substr(0, inc2) + 'x' + matrix[inc1].substr(inc2 + 1);
			}
			if ((matrix[inc1][inc2] == '.')&&(dif_val == 0)&&(people > 0))
			{
				if ((matrix[inc1][inc2-1] != 'S')&&(matrix[inc1][inc2+1] != 'S'))
				{
					matrix[inc1] = matrix[inc1].substr(0, inc2) + 'x' + matrix[inc1].substr(inc2 + 1);
					people--;
				}
			}
			if ((matrix[inc1][inc2] == '.')&&(dif_val == 1))
			{
				if ((matrix[inc1][inc2-1] == 'S')&&(matrix[inc1][inc2+1] == 'S')) {}
				else if ((matrix[inc1][inc2-1] != 'S')&&(matrix[inc1][inc2+1] != 'S'))
					matrix[inc1] = matrix[inc1].substr(0, inc2) + 'x' + matrix[inc1].substr(inc2 + 1);
				else if (people > 0)
				{
					matrix[inc1] = matrix[inc1].substr(0, inc2) + 'x' + matrix[inc1].substr(inc2 + 1);
					people--;
				}
			}
		}
		print(matrix[inc1]);
	}


mas=readline().split(' ');
v1=parseInt(mas[0])*2;
v2=parseInt(mas[1])*2;
v3=parseInt(mas[2]);
vm=parseInt(mas[3])*2;
no=false;
if(v1 <= vm) {
    no=true;
}
if(v2 <= vm) {
    no=true;
}
vm=vm/2;
if(v3 > vm) {
    min = vm;
    max = v3;
} else {
    min = v3;
    max = vm;
}

if(max > min*2 || no) {
    print('-1');
} else {
    print(v1);
    print(v2);
    print(max);
}

var N = readline().split(' ');
var a1 = parseInt(N[0]),a2 = parseInt(N[1]),a3 = parseInt(N[2]),a4 = parseInt(N[3]);
var b1left = a1 , b2left = a2 ,b3left = a3;
var b1right = 2 * a1 , b2right = 2 *a2 , b3right = 2 * a3 ;
var b1=0, b2=0, b3=0;
for(var i=200;i>=0;i--){
  if(i>=b1left && i <= b1right && b1 == 0 && a4 <= i && i > 2 * a4) {
      b1 = i;
      continue;
  }
  if(i >= b2left && i <= b2right && b2 ==0 && a4 <= i && i > 2 * a4) {
    b2 = i;
    continue;
  }
  if(i >= b3left && i <= b3right && a4 <= i && i <= 2 * a4){
    b3 = i;
    break;
  }

}

if(b1 == 0 || b2 == 0 || b3 == 0){
  print("-1");
}
else{
  print(b1);
  print(b2);
  print(b3);
}

'use strict'

const input = readline();

// const print = console.log;
// const line0 = "50 30 10 19";

// const input = line0;
const arr = input.split(' ').map(x => parseInt(x));

const bear3 = arr[0];
const bear2 = arr[1];
const bear1 = arr[2];
const masha = arr[3];

const car1_low = bear1;
const car2_low = bear2;
const car3_low = bear3;

const car1_high = bear1 * 2;
const car2_high = bear2 * 2;
const car3_high = bear3 * 2;

const masha_likes_low = masha;
const masha_likes_high = masha * 2;

if (masha_likes_low > car1_high || masha_likes_high < car1_low || masha_likes_high >= car2_high) {
    print(-1);
} else {
    const car1 = masha_likes_low < car1_low ? car1_low : masha_likes_low;
    print(car3_high);
    print(car2_high);
    print(car1);
}

var line = readline();
var bears = line.split(' ').map(function(x) {return parseInt(x)});
var big = 2 * bears[0];
var medium = Math.min(2 * bears[1], big - 1);
var small = Math.min(2 * bears[2], 2 * bears[3], medium - 1);

if (bears[1] > medium ||
    bears[2] > small ||
    bears[3] > small ||
    2 * bears[3] >= big ||
    2 * bears[3] >= medium) {
    print(-1);
} else {
  print(big);
  print(medium);
  print(small);
}

/**
 * 已知 a1 a2 a3 a4
 *  b1>b2>b3   a1<=b1<=2a1   b3<=a4<=2b3
 */

var N = readline().split(' ');
var a1 = parseInt(N[0]),a2 = parseInt(N[1]),a3 = parseInt(N[2]),a4 = parseInt(N[3]);
var b1left = a1 , b2left = a2 ,b3left = a3;
var b1right = 2 * a1 , b2right = 2 *a2 , b3right = 2 * a3 ;
var b1=0, b2=0, b3=0;
for(var i=200;i>=0;i--){
  if(i>=b1left && i <=b1right){
      b1 = i;
      continue;
  }
  if(i >= b2left && i <= b2right){
    b2 = i;
    continue;
  }
  if(i >= b3left && i <= b3right && b3left <= a4 && a4 <= b3right){
    b3 = i;
  }

}

if(b1 == 0 || b2 == 0 || b3 == 0){
  print("-1");
}
else{
  print(b1);
  print(b2);
  print(b3);
}

var N = readline().split(' ');
var a1 = parseInt(N[0]),a2 = parseInt(N[1]),a3 = parseInt(N[2]),a4 = parseInt(N[3]);
var b1left = a1 , b2left = a2 ,b3left = a3;
var b1right = 2 * a1 , b2right = 2 *a2 , b3right = 2 * a3 ;
var b1=0, b2=0, b3=0;
for(var i=200;i>=0;i--){
  if(i>=b1left && i <= b1right && b1 == 0) {
      b1 = i;
      continue;
  }
  if(i >= b2left && i <= b2right && b2 ==0) {
    b2 = i;
    continue;
  }
  if(i >= b3left && i <= b3right && a4 <= i && i <= 2 * a4){
    b3 = i;
    break;
  }

}

print(b1, b2, b3);

if(b1 == 0 || b2 == 0 || b3 == 0){
  print("-1");
}
else{
  print(b1);
  print(b2);
  print(b3);
}

var N = readline().split(' ');
var a1 = parseInt(N[0]),a2 = parseInt(N[1]),a3 = parseInt(N[2]),a4 = parseInt(N[3]);
var b1left = a1 , b2left = a2 ,b3left = a3;
var b1right = 2 * a1 , b2right = 2 *a2 , b3right = 2 * a3 ;
var b1=0, b2=0, b3=0;
for(var i=200;i>=0;i--){
  if(i>=b1left && i <= b1right && b1 == 0) {
      b1 = i;
      continue;
  }
  if(i >= b2left && i <= b2right && b2 ==0) {
    b2 = i;
    continue;
  }
  if(i >= b3left && i <= b3right && a4 <= i && i <= 2 * a4){
    b3 = i;
    break;
  }

}

if(b1 == 0 || b2 == 0 || b3 == 0){
  print("-1");
}
else{
  print(b1);
  print(b2);
  print(b3);
}

mas=readline().split(' ');
v1=parseInt(mas[0])*2;
v2=parseInt(mas[1])*2;
v3=parseInt(mas[2])*2;
vm=parseInt(mas[3])*2;
no=false;
if(v1 <= vm) {
    no=true;
}
if(v2 <= vm) {
    no=true;
}
if(v3 <= vm) {
    no=true;
}

if(no) {
    print('-1');
} else {
    print(v1);
    print(v2);
    print(v3);
}

mas=readline().split(' ');
v1=parseInt(mas[0])*2;
v2=parseInt(mas[1])*2;
v3=parseInt(mas[2])*2;
vm=parseInt(mas[3])*2;
no=false;
if(v1 <= vm) {
    no=true;
}
if(v2 <= vm) {
    no=true;
}
if(v3 < vm) {
    no=true;
}

if(no) {
    print('-1');
} else {
    print(v1);
    print(v2);
    print(v3);
}

mas=readline().split(' ');
v1=parseInt(mas[0]);
v2=parseInt(mas[1]);
v3=parseInt(mas[2]);
vm=parseInt(mas[3]);
no=false;
if(v1 <= vm*2) {
    if (vm*2+2 <= v1*2) {
        v1 = vm*2+2;
    } else {
        no=true;
    }
}
if(v2 <= vm*2) {
    if (vm*2+1 <= v2*2) {
        v2 = vm*2+1;
    } else {
        no=true;
    }
}
if(v3 > vm) {
    min = vm;
    max = v3;
} else {
    min = v3;
    max = vm;
}

if(max > min*2 || no) {
    print('-1');
} else {
    print(v1);
    print(v2);
    print(max);
}

mas=readline().split(' ');
v1=parseInt(mas[0]);
v2=parseInt(mas[1]);
v3=parseInt(mas[2]);
vm=parseInt(mas[3]);
no=false;
if(v1 <= vm*2) {
    if (vm*2+1 <= v1*2) {
        v1 = vm*2+1;
    } else {
        no=true;
    }
}
if(v2 <= vm*2) {
    if (vm*2+1 <= v2*2) {
        v2 = vm*2+1;
    } else {
        no=true;
    }
}
if(v3 > vm) {
    min = vm;
    max = v3;
} else {
    min = v3;
    max = vm;
}

if(max > min*2 || no) {
    print('-1');
} else {
    print(v1);
    print(v2);
    print(max);
}

mas=readline().split(' ');
v1=parseInt(mas[0]);
v2=parseInt(mas[1]);
v3=parseInt(mas[2]);
vm=parseInt(mas[3]);
if(v3 > vm) {
    min = vm;
    max = v3;
} else {
    min = v3;
    max = vm;
}

if(max > min*2) {
    print('-1');
} else {
    print(v1);
    print(v2);
    print(max);
}

var line = readline();
var bears = line.split(' ').map(function(x) {return parseInt(x)});
var big = 2 * bears[0];
var medium = Math.min(2 * bears[1], big - 1);
var small = Math.min(2 * bears[2], 2 * bears[3], medium - 1);

if (bears[1] > medium || bears[2] > small || bears[3] > small) {
    print(-1);
} else {
  print(big);
print(medium);
print(small);
}


var args = readline().split(' ').map((s) => parseInt(s, 10));

var length = args[0];
var k = args[1];
var arr = readline().split(' ').map((s) => parseInt(s, 10));

function main(length, k, arr) {
    var sorted = arr.sort((a, b) => a - b);

    if (k === 0) {
        var smallest = arr[k];

        return smallest > 1 ? smallest - 1 : -1;
    }

    var border = arr[k - 1];

    if (border === arr[k]) {
        return -1;
    }

    return border;
}

print(main(length, k, arr));

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let stdinInput = '';

process.stdin.on('data', input => {
  stdinInput += input;
})

process.stdin.on('end', () => {
  main(stdinInput);
})

function main(data) {
    data = data.split(/\r?\n/);
    const split = data[0].split(" ");
    const count = split[0]
    const k = split[1]
    const n = data[1]

    solve(n,k,count)
}

function solve(n, k, count) {
    let sorted = n.split(" ").map( x => x * 1).sort((a,b) => a - b)
    if (k === "0" && sorted[0] > 1) {
        console.log(sorted[0] - 1)
        return
    }

    if (k === "0" ||
        sorted.length < k ||
        sorted[k-1] === sorted[k] ||
        sorted[k - 1] < 1) {
        console.log(-1)
    } else {
        console.log(sorted[k - 1])
    }
}

var s = readline().split(' ');
var n = +s[0];
var k = +s[1]
var a = readline().split(' ');
a.sort(function(a, b){return a-b});
if(k == 0){
    if(a[0] > 1){
        print('1');
    } else{
        print('-1');
    }
} else if(k < n && a[k-1] == a[k]){
    print('-1');
} else{
    print(a[k-1]);
}

// https://codeforces.com/problemset/problem/977/C
// Big O:
// Time complexity:
// Space complexity:

const readline = require("readline");

// Read input
var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

let kValue;
rl.on('line', (input) => {
    if (kValue != undefined) {
        const numbers = input.split(" ").map(Number);
        console.log(findLessOrEqual(numbers, kValue));
        rl.close();
    } else {
        kValue = parseInt(input.split(" ")[1]);
    }
});

// Problem
function findLessOrEqual(numbers, kValue) {
    const orderedNumbers = numbers.sort((a, b) => a - b);

    if (kValue === numbers.length) {
        return numbers[kValue - 1];
    }

    const numberAtKPos = orderedNumbers[kValue];
    const lessOrEqualValue = numberAtKPos - 1;

    if (lessOrEqualValue === 0) {
        return -1;
    }

    if (kValue === 0) {
        return numberAtKPos > lessOrEqualValue ? lessOrEqualValue : -1;
    }

    const index = kValue - 1;
    const comparisonNumber = orderedNumbers[index];
    return comparisonNumber <= lessOrEqualValue ? comparisonNumber : -1;
}

// https://codeforces.com/problemset/problem/977/C
// Big O:
// Time complexity: O(n*log(n))
// Space complexity: O(n)

const readline = require("readline");

// Read input
var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

let kValue;
rl.on('line', (input) => {
    if (kValue != undefined) {
        const numbers = input.split(" ").map(Number);
        console.log(findLessOrEqual(numbers, kValue));
        rl.close();
    } else {
        kValue = parseInt(input.split(" ")[1]);
    }
});

// Problem
function findLessOrEqual(numbers, kValue) {
    const orderedNumbers = numbers.sort((a, b) => a - b);

    if (kValue === numbers.length) {
        return numbers[kValue - 1];
    }

    const numberAtKPos = orderedNumbers[kValue];
    const comparisonValue = numberAtKPos - 1;

    if (comparisonValue === 0) {
        return -1;
    }

    if (kValue === 0) {
        return comparisonValue;
    }

    const previousNumber = orderedNumbers[kValue - 1];
    return previousNumber <= comparisonValue ? previousNumber : -1;
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let stdinInput = '';

process.stdin.on('data', input => {
  stdinInput += input;
})

process.stdin.on('end', () => {
  main(stdinInput);
})

function main(data) {
    data = data.split(/\r?\n/);
    const split = data[0].split(" ");
    const count = split[0]
    const k = split[1]
    const n = data[1]

    solve(n,k,count)
}

function solve(n, k, count) {
    let sorted = n.split(" ").map( x => x * 1).sort((a,b) => a - b)
    if (sorted.length < k ||
        sorted[k-1] === sorted[k] || k === 0) {
        console.log(-1)
    } else {
        console.log(sorted[k - 1])
    }
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let stdinInput = '';

process.stdin.on('data', input => {
  stdinInput += input;
})

process.stdin.on('end', () => {
  main(stdinInput);
})

function main(data) {
    data = data.split(/\r?\n/);
    const split = data[0].split(" ");
    const count = split[0]
    const k = split[1]
    const n = data[1]

    solve(n,k,count)
}

function solve(n, k, count) {
    let sorted = n.split(" ").map( x => x * 1).sort((a,b) => a - b)
    if (k === "0" && sorted[0] > 1) {
        console.log(sorted[0] - 1)
        return
    }

    if (sorted.length < k ||
        sorted[k-1] === sorted[k] ||
        sorted[k - 1] <= 1) {
        console.log(-1)
    } else {
        console.log(sorted[k - 1])
    }
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let stdinInput = '';

process.stdin.on('data', input => {
  stdinInput += input;
})

process.stdin.on('end', () => {
  main(stdinInput);
})

function main(data) {
    data = data.split(/\r?\n/);
    const split = data[0].split(" ");
    const count = split[0]
    const k = split[1]
    const n = data[1]

    solve(n,k,count)
}

function solve(n, k, count) {
    let sorted = n.split(" ").map( x => x * 1).sort((a,b) => a - b)
    if (sorted.length < k ||
        sorted[k-1] === sorted[k] || k === "0") {
        console.log(-1)
    } else {
        console.log(sorted[k - 1])
    }
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let stdinInput = '';

process.stdin.on('data', input => {
  stdinInput += input;
})

process.stdin.on('end', () => {
  main(stdinInput);
})

function main(data) {
    data = data.split(/\r?\n/);
    const split = data[0].split(" ");
    const count = split[0]
    const k = split[1]
    const n = data[1]

    solve(n,k,count)
}

function solve(n, k, count) {
    let sorted = n.split(" ").map( x => x * 1).sort((a,b) => a - b)
    if (k === "0" && sorted[0] > 1) {
        console.log(sorted[0] - 1)
        return
    }

    if (k === "0" ||
        sorted.length < k ||
        sorted[k-1] === sorted[k] ||
        sorted[k - 1] <= 1) {
        console.log(-1)
    } else {
        console.log(sorted[k - 1])
    }
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let stdinInput = '';

process.stdin.on('data', input => {
  stdinInput += input;
})

process.stdin.on('end', () => {
  main(stdinInput);
})

function main(data) {
    data = data.split(/\r?\n/);
    const split = data[0].split(" ");
    const count = split[0]
    const k = split[1]
    const n = data[1]

    solve(n,k,count)
}

function solve(n, k, count) {
    let sorted = n.split(" ").map( x => x * 1).sort((a,b) => a - b)
    if (k === "0" && sorted[0] >= 1) {
        console.log(sorted[0] - 1)
        return
    } else {
        console.log(-1)
        return
    }

    if (sorted.length < k ||
        sorted[k-1] === sorted[k] ||
        sorted[k - 1] <= 1) {
        console.log(-1)
    } else {
        console.log(sorted[k - 1])
    }
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let stdinInput = '';

process.stdin.on('data', input => {
  stdinInput += input;
})

process.stdin.on('end', () => {
  main(stdinInput);
})

function main(data) {
    data = data.split(/\r?\n/);
    const split = data[0].split(" ");
    const count = split[0]
    const k = split[1]
    const n = data[1]

    solve(n,k,count)
}

function solve(n, k, count) {
    let sorted = n.split(" ").map( x => x * 1).sort((a,b) => a - b)
    if (k === "0" && sorted[0] >= 1) {
        console.log(sorted[0] - 1)
        return
    }

    if (sorted.length < k ||
        sorted[k-1] === sorted[k] ||
        sorted[k - 1] <= 1) {
        console.log(-1)
    } else {
        console.log(sorted[k - 1])
    }
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let stdinInput = '';

process.stdin.on('data', input => {
  stdinInput += input;
})

process.stdin.on('end', () => {
  main(stdinInput);
})

function main(data) {
    data = data.split(/\r?\n/);
    const split = data[0].split(" ");
    const count = split[0]
    const k = split[1]
    const n = data[1]

    solve(n,k,count)
}

function solve(n, k, count) {
    let sorted = n.split(" ").map( x => x * 1).sort((a,b) => a - b)
    if (sorted.length < k ||
        sorted[k-1] === sorted[k]) {
        console.log(-1)
    } else {
        console.log(sorted[k - 1])
    }
}

// https://codeforces.com/problemset/problem/977/C
// Big O:
// Time complexity:
// Space complexity:

const readline = require("readline");

// Read input
var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

let kValue;
rl.on('line', (input) => {
    if (kValue != undefined) {
        const numbers = input.split(" ").map(Number);
        console.log(findLessOrEqual(numbers, kValue));
        rl.close();
    } else {
        kValue = parseInt(input.split(" ")[1]);
    }
});

// Problem
function findLessOrEqual(numbers, kValue) {
    const orderedNumbers = numbers.sort((a, b) => a - b);
    const numberAtKIndex = orderedNumbers[kValue - 1];
    const isKValidIndex = kValue < numbers.length
    const isNextNumberLessThanK = isKValidIndex && orderedNumbers[kValue] <= numberAtKIndex ? true : false;
    const isNumberHigherThanK = numberAtKIndex >= kValue
    return isNumberHigherThanK && !isNextNumberLessThanK ? numberAtKIndex : -1;
}

// https://codeforces.com/problemset/problem/977/C
// Big O:
// Time complexity:
// Space complexity:

const readline = require("readline");

// Read input
var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

let kValue;
rl.on('line', (input) => {
    if (kValue) {
        const numbers = input.split(" ").map(Number);
        console.log(findLessOrEqual(numbers, kValue));
        rl.close();
    } else {
        kValue = input.split(" ")[1];
    }
});

// Problem
function findLessOrEqual(numbers, kValue) {
    if (kValue === 0) {
        return -1;
    }
    const orderedNumbers = numbers.sort((a, b) => a - b);
    const numberAtKValueIndex = orderedNumbers[kValue - 1];
    const isThereANextNumber = kValue < numbers.length
    const isNextNumberLessThanK = isThereANextNumber && orderedNumbers[kValue] <= numberAtKValueIndex ? true : false;
    return kValue <= numberAtKValueIndex && !isNextNumberLessThanK ? numberAtKValueIndex : -1;
}

// https://codeforces.com/problemset/problem/977/C
// Big O:
// Time complexity:
// Space complexity:

const readline = require("readline");

// Read input
var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

let kValue;
rl.on('line', (input) => {
    if (kValue) {
        const numbers = input.split(" ").map(Number);
        console.log(findLessOrEqual(numbers, kValue));
        rl.close();
    } else {
        kValue = parseInt(input.split(" ")[1]);
    }
});

// Problem
function findLessOrEqual(numbers, kValue) {
    if (kValue === 0) {
        return -1;
    }
    const orderedNumbers = numbers.sort((a, b) => a - b);
    const numberAtKIndex = orderedNumbers[kValue - 1];
    const isKValidIndex = kValue < numbers.length
    const isNextNumberLessThanK = isKValidIndex && orderedNumbers[kValue] <= numberAtKIndex ? true : false;
    const isNumberHigherThanK = numberAtKIndex >= kValue
    return isNumberHigherThanK && !isNextNumberLessThanK ? numberAtKIndex : -1;
}

// https://codeforces.com/problemset/problem/977/C
// Big O:
// Time complexity:
// Space complexity:

const readline = require("readline");

// Read input
var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

let kValue;
rl.on('line', (input) => {
    if (kValue) {
        const numbers = input.split(" ").map(Number);
        console.log(findLessOrEqual(numbers, kValue));
        rl.close();
    } else {
        kValue = input.split(" ")[1];
    }
});

// Problem
function findLessOrEqual(numbers, kValue) {
    const orderedNumbers = numbers.sort((a, b) => a - b);
    const numberAtKValueIndex = orderedNumbers[kValue - 1];
    const isThereANextNumber = kValue < numbers.length
    const isNextNumberLessThanK = isThereANextNumber && orderedNumbers[kValue] <= numberAtKValueIndex ? true : false;
    return kValue <= numberAtKValueIndex && !isNextNumberLessThanK ? numberAtKValueIndex : -1;
}

// https://codeforces.com/problemset/problem/977/C
// Big O:
// Time complexity:
// Space complexity:

const readline = require("readline");

// Read input
var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

let kValue;
rl.on('line', (input) => {
    if (kValue) {
        const numbers = input.split(" ").map(Number);
        console.log(findLessOrEqual(numbers, kValue));
        rl.close();
    } else {
        kValue = parseInt(input.split(" ")[1]);
    }
});

// Problem
function findLessOrEqual(numbers, kValue) {
    if (kValue === 0) {
        return -1;
    }
    const orderedNumbers = numbers.sort((a, b) => a - b);
    const numberAtKValue = orderedNumbers[kValue - 1];
    const isKValidIndex = kValue < numbers.length
    const isNextNumberHigherThanK = isKValidIndex && orderedNumbers[kValue] > numberAtKValue ? false : true;
    const isNumberHigherThanK = numberAtKValue >= kValue
    return isNumberHigherThanK && isNextNumberHigherThanK ? numberAtKValue : -1;
}

// https://codeforces.com/problemset/problem/977/C
// Big O:
// Time complexity:
// Space complexity:

const readline = require("readline");

// Read input
var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

let kValue;
rl.on('line', (input) => {
    if (kValue != undefined) {
        const numbers = input.split(" ").map(Number);
        console.log(findLessOrEqual(numbers, kValue));
        rl.close();
    } else {
        kValue = parseInt(input.split(" ")[1]);
    }
});

// Problem
function findLessOrEqual(numbers, kValue) {
    const orderedNumbers = numbers.sort((a, b) => a - b);
    const numberAtKPos = orderedNumbers[kValue];
    const lessOrEqualValue = numberAtKPos - 1;

    if (lessOrEqualValue === 0) {
        return -1;
    }

    if (kValue === 0) {
        return numberAtKPos > lessOrEqualValue ? lessOrEqualValue : -1;
    }

    const index = kValue - 1;
    const comparisonNumber = orderedNumbers[index];
    return comparisonNumber <= lessOrEqualValue ? comparisonNumber : -1;
}

// https://codeforces.com/problemset/problem/977/B
// Big O:
// Time complexity: O(n)
// Space complexity: O(n)

const readline = require("readline");

// Read input
var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

let stringLength;
rl.on('line', (input) => {
    if (stringLength) {
        console.log(findMostCommonGram(input, stringLength));
        rl.close();
    } else {
        stringLength = input;
    }
});

// Problem
function findMostCommonGram(string, stringLength) {
    let mostCommonGram = "";
    let mostCommonGramOccurrences = 0;
    const gramOccurrences = {};

    for (let i = 0; i < stringLength - 1; i++) {
        const twogram = string[i] + string[i + 1];
        const occurrences = gramOccurrences[twogram] ? gramOccurrences[twogram] + 1 : 1;
        const currentOcurrences = occurrences + 1;
        if (currentOcurrences > mostCommonGramOccurrences) {
            mostCommonGram = twogram;
            mostCommonGramOccurrences = currentOcurrences;
        }

        gramOccurrences[twogram] = currentOcurrences;
    }

    return mostCommonGram;
}

var args = readline().split(' ').map((s) => parseInt(s, 10));

var length = args[0];
var k = args[1];
var arr = readline().split(' ').map((s) => parseInt(s, 10));

function main(length, k, arr) {
    var sorted = arr.sort((a, b) => a - b);

    var border = arr[k - 1];

    if (border === arr[k]) {
        return -1;
    }

    return border;
}

print(main(length, k, arr));

var args = readline().split(' ').map((s) => parseInt(s, 10));

var length = args[0];
var k = args[1];
var arr = readline().split(' ').map((s) => parseInt(s, 10));

function main(length, k, arr) {
    if (k === 0) {
        return -1;
    }

    var sorted = arr.sort((a, b) => a - b);

    var border = arr[k - 1];

    if (border === arr[k]) {
        return -1;
    }

    return border;
}

print(main(length, k, arr));

var s = readline().split(' ');
var n = +s[0];
var k = +s[1]
var a = readline().split(' ');
a.sort(function(a, b){return a-b});
if(k < n && a[k-1] == a[k] || k == 0){
    print('-1');
} else{
    print(a[k-1]);
}

var s = readline().split(' ');
var n = +s[0];
var k = +s[1]
var a = readline().split(' ');
a.sort(function(a, b){return a-b});
if(k < n && a[k-1] == a[k]){
    print('-1');
} else{
    print(a[k-1]);
}


// Sample code to perform I/O:

process.stdin.resume();
process.stdin.setEncoding("utf-8");
var stdin_input = "";

process.stdin.on("data", function (input) {
    stdin_input += input;                               // Reading input from STDIN
});

process.stdin.on("end", function () {
    main(stdin_input);
});

function main(input) {
    let output = nameLookUp(input);
    process.stdout.write(output);       // Writing output to STDOUT
}

// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail

// Write your code here
function nameLookUp(str) {

    let inputs = str.trim().split('\n');
    let polyhedrons = {
        'Tetrahedron': 4,
        'Cube': 6,
        'Octahedron': 8,
        'Dodecahedron': 12,
        'Icosahedron': 20,
    };
    let sum = 0;
    let shapes = inputs.slice(1);
    for (let row of shapes) {
        if (polyhedrons[row.trim()]) {
            sum += polyhedrons[row.trim()];
        }
    }

    return sum.toString();
}

var sum = 0;
		var n = readline();
		while(n>0){
		var line = readline();
		if (line == "Tetrahedron"){
			sum+=4;
		}
		if (line == "Cube"){
			sum+=6;
		}
		if (line == "Octahedron"){
			sum+=8;
		}
		if (line == "Dodecahedron"){
			sum+=12;
		}
		if (line == "Icosahedron"){
			sum+=20;
		}
		n--;
	}
		print(sum);

  var n = parseInt(readline());
  var res = 0;
  while(n) {
    var c = readline();
    if(c === 'Tetrahedron') res += 4;
    if(c === 'Cube') res += 6;
    if(c === 'Octahedron') res += 8;
    if(c === 'Dodecahedron') res += 12;
    if(c === 'Icosahedron') res += 20;
    n -= 1;
  }
  print(res)

var n = parseInt(readline()), i = 0;
var s, res=0;

for(i=0;i<n;i++)
{
  s = 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;
}

print(res);

	 var n = parseInt(readline());
	var sum = 0;
     while(n){
     	var str = readline();
     	if(str === "Tetrahedron") sum += 4;
     	if(str === "Cube") sum += 6;
     	if(str === "Octahedron") sum += 8;
     	if(str === "Dodecahedron") sum += 12;
     	if(str === "Icosahedron") sum += 20;
     	n --;
     }
     print(sum);

	 var n = parseInt(readline());
	var sum = 0;
     while(n){
     	var str = readline();
     	if(str === "Tetrahedron") sum += 4;
     	if(str === "Cube") sum += 6;
     	if(str === "Octahedron") sum += 8;
     	if(str === "Dodecahedron") sum += 12;
     	if(str === "Icosahedron") sum += 20;
     	n -= 1;
     }
     print(sum);

var lineNumber = readline();
var coubes = new Map();
coubes.set("Tetrahedron", 4);
coubes.set("Cube", 6);
coubes.set("Octahedron", 8);
coubes.set("Dodecahedron", 12);
coubes.set("Icosahedron", 20);
var count = 0;
while(lineNumber--){
    var input = readline();
    count += coubes.get(input);
}
print(count);

var n = readline();
var fig = {Tetrahedron: 4, Cube : 6, Octahedron: 8, Dodecahedron : 12, Icosahedron : 20 };
var fete = 0;
for( i=0;i<n;i++) {
      fete+=fig[readline()];
}
print(fete);

var a = readline(),i = 0,k = 0;
var s;
while(i != a)
{
	s = readline();
	if(s == "Tetrahedron")
	{
		k += 4;
	}
	else	if(s == "Cube")
		{
			k += 6;
		}
		else	if(s == "Octahedron")
			{
				k += 8;
			}
			else	if(s == "Dodecahedron")
				{
					k += 12;
				}
				else	if(s == "Icosahedron")
					{
						k += 20;
					}
	i++;
}
print(k);

var n = Number(readline());
var arr = [];

for(var i = 0; i < n; i++) {
    arr.push(readline());
}

var obj = {
    'Tetrahedron': 4,
    'Cube': 6,
    'Octahedron': 8,
    'Dodecahedron': 12,
    'Icosahedron': 20
}

var result = 0;
arr.map(item => result += obj[item])

print(result)

'use strict'
let a = readline(), b, c = 0;

for (; a; a--) {
  b = readline()[0];
  if (b === 'C') {c += 6; continue}
  if (b === 'D') {c += 12; continue}
  if (b === 'I') {c += 20; continue}
  if (b === 'O') {c += 8; continue}
  if (b === 'T') {c += 4; continue}
}

print(c);

var n = parseInt(readline()),
	counter = 0,
	scores = {
		Tetrahedron: 4,
		Cube: 6,
		Octahedron: 8,
		Dodecahedron: 12,
		Icosahedron: 20
	}

while (n > 0) {
	counter += scores[readline()]
	n --
}

print(counter)

var data1 = readline().split(' ').map(function(x){return parseInt(x)});
var data2 = [];
for (i = 0; i<data1[0]; i++){
	data2.push(readline());
}

var result = solution(data1[0], data2);
print(result);

// End of interface

function solution(n, s){
	var res = 0;
	for(i = 0; i < n; i++){
			switch (s[i]) {
				case 'Tetrahedron':
					res = res + 4;
					break;
				case 'Cube':
					res = res + 6;
					break;
				case 'Octahedron':
					res = res + 8;
					break;
				case 'Dodecahedron':
					res = res + 12;
					break;
				case 'Icosahedron':
					res = res + 20;
					break;
			}
	}
	return res;
};

var a = readline(), b, c = 0;

for (; a; a--) {
  b = readline()[0];
  if (b === 'C') {c += 6; continue;}
  if (b === 'D') {c += 12; continue;}
  if (b === 'I') {c += 20; continue;}
  if (b === 'O') {c += 8; continue;}
  if (b === 'T') {c += 4; continue;}
}

print(c);

var dic = {"Tetrahedron":4 , "Cube":6 , "Octahedron":8 , "Dodecahedron":12 , "Icosahedron":20};
var n = 0;
var step = Number(readline());
for (i = 0 ; i <step ; i++){
    n += dic[readline()]
}
print(n)

function ansa(t,arr){

  var face = 0;
  for(var i = 0 ; i < t ; i++){
    if(arr[i] === "Tetrahedron" )face += 4;
    else if(arr[i] === "Cube" )face += 6;
    else if(arr[i] === "Octahedron" )face += 8;
    else if(arr[i] === "Dodecahedron" )face += 12;
    else face += 20;
  }
    print(face);
    return;
}

var line = readline();
line = parseInt(line);
var shapes = []
for(var i = 0 ; i < line ; i++ ){
  shapes[i] = readline()
}
ansa(line,shapes);
// for(var i = 0 ; i < line.length ; i++) line[i] = parseInt(line[i]);
// var line2 = readline().split(' ');
// for(var i = 0 ; i < line2.length ; i++) line2[i] = parseInt(line2[i]);

// ansa(parseInt(line),arr);

var data = {
	"Tetrahedron": 4,
	"Cube": 6,
	"Octahedron": 8,
	"Dodecahedron": 12,
	"Icosahedron": 20
};

var n = +readline(),
	sum = 0,
	line;

while (line = readline()) {
	sum += data[line];
}

print(sum);

var p = {Tetrahedron: 4, Cube: 6, Octahedron: 8, Dodecahedron: 12, Icosahedron: 20};
n = parseInt(readline());
var s = 0;
 for (var i=0; i < n; i++ ){
     s += p[readline()];
 }
print(s);

"use strict";

// readline().split(' ').map(value => +value);
var S = {
    'Tetrahedron': 4,
    'Cube': 6,
    'Octahedron': 8,
    'Dodecahedron': 12,
    'Icosahedron': 20
};

var n = readline();

var result = 0;
for (var i = 0; i < n; ++i) {
    result += S[readline()];
}

write(result);

var n=+readline()
var T={
 Tetrahedron: 4,
 Cube: 6,
 Octahedron: 8,
 Dodecahedron: 12,
 Icosahedron:20,
};
R=0
for (var i=0;i<n;++i)
 R+=T[readline()]
print(R)

var numbers = readline();
var a = numbers;
var number = []
var e=[];
var b = 0;

for(var i=0; i<a; i++){
    number.push(readline())
    if(number[i]==='Tetrahedron') {b=b+4}
    if(number[i]==='Cube'){b=b+6}
    if(number[i]==='Octahedron'){b=b+8}
    if(number[i]==='Dodecahedron'){b=b+12}
    if(number[i]==='Icosahedron'){b=b+20}
}

print(b)

var n = Number.parseInt(readline());
var mapping = {
        Tetrahedron: 4,
        Cube: 6,
        Octahedron: 8,
        Dodecahedron: 12,
        Icosahedron: 20
    };
var result = 0;

for (var i = 0; i < n; i++) {
    result += mapping[readline()];
}

print(result);

var shapes = {
  "Tetrahedron": 4,
  "Cube": 6,
  "Octahedron": 8,
  "Dodecahedron": 12,
  "Icosahedron": 20,
}

var numberOfShape = Number(readline())

var numberOfFaces = 0

for (var i = 0; i < numberOfShape; i++) {
  var shape = readline()
  numberOfFaces += shapes[shape]
}

print(numberOfFaces)

var array = {"Tetrahedron": 4, "Cube": 6, "Octahedron": 8, "Dodecahedron": 12, "Icosahedron": 20};
var n = parseInt(readline());

var sum=0;
for (var i = 0; i < n; i++) {
    var key=readline();
    sum+=array[key];
}

print(sum);

var input = parseInt(readline());
 var obj = {
     'Tetrahedron':4,
     'Cube':6,
     'Octahedron':8,
     'Dodecahedron':12,
     "Icosahedron": 20,
 }

 var count =0;
 for(var i = 0; i<input ; i++){
     count += obj[readline()];
 }
 print(count);

  var n = parseInt(readline());
  var res = 0;
  while(n) {
    var c = readline();
    if(c === 'Tetrahedron') res += 4;
    if(c === 'Cube') res += 6;
    if(c === 'Octahedron') res += 8;
    if(c === 'Dodecahedron') res += 12;
    if(c === 'Icosahedron') res += 20;
    n -= 1;
  }
  print(res)

(function() {
    'use strict';
    const n = readline();
    var sum = 0;
    for (var i = 0; i < n; ++i) {
        const figure = readline();
        if (figure == "Tetrahedron")
            sum += 4;
        if (figure == "Cube")
            sum += 6;
        if (figure == "Octahedron")
            sum += 8;
        if (figure == "Dodecahedron")
            sum += 12;
        if (figure == "Icosahedron")
            sum += 20;
    }

    print(sum);
}());

var res = sol(readline());
print(res);

function sol(line) {
    var input = line.split(" ");

    var n = input[0];
    var faces = 0;

    while(n > 0){
        var name = readline();

        if(name == "Tetrahedron"){
            faces += 4;
        }else if(name == "Cube"){
            faces += 6;
        }else if(name == "Octahedron"){
            faces += 8;
        }else if(name == "Dodecahedron"){
            faces += 12;
        }else if(name == "Icosahedron"){
            faces += 20;
        }
        n--;
    }

    return faces;
}

var limit = parseInt(readline());
var map = {}
map['Icosahedron'] = 20;
map['Dodecahedron'] = 12;
map['Octahedron'] = 8;
map['Cube'] = 6;
map['Tetrahedron'] = 4;
var sum = 0;
for (var i = 0; i < limit; i++) {
  sum += map[readline()];
}
print(sum);

var amount = parseInt(readline());
var numberOfFaces = 0;

var polyhedrons = {
    Tetrahedron: 4,
    Cube: 6,
    Octahedron: 8,
    Dodecahedron: 12,
    Icosahedron: 20
}

for (var i = 0; i < amount; i++) {
    numberOfFaces += polyhedrons[readline()];
}

print(numberOfFaces);

var n = parseInt(readline());
var log = {Tetrahedron: 4, Cube: 6, Octahedron: 8, Dodecahedron: 12, Icosahedron:20};
var sideCount = 0;
while (n--) {
	sideCount += log[readline()];
}
print(sideCount);

var o = {
    'Tetrahedron': 4,
    'Cube': 6,
    'Octahedron': 8,
    'Dodecahedron': 12,
    'Icosahedron': 20
}
var n = parseInt(readline())
var total = 0;
while (n != 0) {
    n--;
    total += o[readline().trim()]
}
print(total)

'use strict'
let n = parseInt(readline()),
    dict = {
      Tetrahedron: 4,
      Cube: 6,
      Octahedron: 8,
      Dodecahedron: 12,
      Icosahedron: 20
    },
    counter = 0;

for (let i = 0; i < n; i++) {
  const key = readline();
  counter+=dict[key];
}
write(counter);

var n = +readline(),
    ans = 0;

for (var i = 0; i < n; i++) {
  var name = readline();

  switch (name) {
    case "Tetrahedron":
      ans += 4;
      break;
    case "Cube":
      ans += 6;
      break;
    case "Octahedron":
      ans += 8;
      break;
    case "Dodecahedron":
      ans += 12;
      break;
    case "Icosahedron":
      ans += 20;
      break;
  }
}

print(ans);

l=readline();
  n=l;
var tet=0, cub=0, oct=0, dod=0, ico=0;
for (i=0; i<n; i++) {
  v=readline();
  if (v=="Tetrahedron") tet++;
  if (v=="Cube") cub++;
  if (v=="Octahedron") oct++;
  if (v=="Dodecahedron") dod++;
  if (v=="Icosahedron") ico++;
}
sum=4*tet+6*cub+8*oct+12*dod+20*ico;
print(sum)

var n = parseInt(readline());

var total = 0;
var obj = {
    "T": 4,
    "C": 6,
    "O": 8,
    "D": 12,
    "I": 20
}

while (n--) {
    total += obj[readline().slice(0, 1)];
}

print(total);

var N = readline().split(' ');
var n = N;
var sum = 0;
for (N; N>0; N--) {
    var line = line + ' ' + readline().split(' ') ;
}
var type = line.split(' ');

for (n; n>0; n--) {
   switch (type[n]) {
        case 'Tetrahedron': sum = sum + 4; break;
        case 'Cube': sum = sum + 6; break;
        case 'Octahedron': sum = sum + 8; break;
        case 'Dodecahedron': sum = sum + 12; break;
        case 'Icosahedron': sum = sum + 20; break;
    }
}
print (sum);

var n = readline();
var i = 0, sum = 0, arr = '';
for (i; i<n; i++) {
    arr = readline();
    if (arr == 'Icosahedron') sum += 20;
    if (arr == 'Dodecahedron') sum += 12;
    if (arr == 'Octahedron') sum += 8;
    if (arr == 'Cube') sum += 6;
    if (arr == 'Tetrahedron') sum += 4;
}
print (sum);

var number=readline();
var count=0;
var figure={
    "Tetrahedron":4,
    "Cube":6,
    "Octahedron":8,
    "Dodecahedron":12,
    "Icosahedron":20
}

for(var i=0;i<number;i++){
    var figuresName=readline();
    count+=figure[figuresName];
    // print(figure[figuresName])
}
print(count);

var n = readline();
var figure = {
"Cube":6,
"Icosahedron":20,
"Tetrahedron":4,
"Dodecahedron":12,
"Octahedron":8
}
var res = 0;
		for (var i = 0; i<+n; i++){
				var str = readline();
				res+= figure[str];
		}
		print(res);

var nop = parseInt(readline());
var polyhedrons = {
	Tetrahedron:4,
	Cube:6,
	Octahedron:8,
	Dodecahedron:12,
	Icosahedron:20
}

var count = 0 ;

for( i =1 ; i <= nop ; i++ ){
    var p = readline();

    count += polyhedrons[p];
}

print(count);

var polyhedron = {Tetrahedron: 4, Cube: 6, Octahedron: 8, Dodecahedron: 12, Icosahedron: 20},
    n = parseInt(readline()),
    sum = 0;

for(var i = 0; i < n; i++)
    sum += polyhedron[readline()];

print(sum);

var input='';

process.stdin.on('data',(givenInput)=>{
    input+=givenInput;
})

process.stdin.on('end',()=>{
    main(input);
})

const main=(input)=>{

    const n=Number(input.split('\r\n')[0]);
    let strArr=input.split('\r\n');

    let num,total=0;

    for(let i=1;i<=n;i++){

        str=strArr[i];

        switch(str){
            case 'Tetrahedron': num=4; break;
            case 'Cube': num=6; break;
            case 'Octahedron': num=8 ; break;
            case 'Dodecahedron': num=12 ; break;
            case 'Icosahedron': num=20 ; break;
        }

        total+=num;
    }

    console.log(total);

}

const readLine = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout,
});

const input = [];
readLine.on('line', line => input.push(line));
const polyhedron = () => {
    input.shift();
    let sum = 0;
    for (const x of input) {
         if (x === 'Icosahedron') {
            sum += 20;
         }if (x === 'Cube') {
            sum += 6;
         }if (x === 'Tetrahedron') {
            sum += 4;
         }if (x === 'Dodecahedron') {
            sum += 12;
         }   if (x === 'Octahedron') {
            sum += 8;
         }
    }
    console.log(sum);
};
readLine.on('close', polyhedron);

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});

function readLine() {
    return inputString[currentLine++];
}

function main() {
    let n = parseInt(readLine());
    let ans = 0;
    let objPoly = {
        T: 4,
        C: 6,
        O: 8,
        D: 12,
        I: 20
    }
    for (var i = 0; i < n; i++) {
        let polyhedron = readLine();
        ans += objPoly[polyhedron.charAt(0)];
    }
    console.log(ans);
}

'use strict';

const readline = require('readline');

let lines = [];

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

rl.on('line', (line) => {
    lines.push(line);
});

rl.on('close', (cmd) => {
    let n = parseInt(lines[0]);
    let obj = {
        "Cube":        6,
        "Dodecahedron": 12,
        "Icosahedron": 20,
        "Octahedron":  8,
        "Tetrahedron": 4
    };
    let ret = 0;
    for (let i = 1; i < n + 1; ++i) {
        ret += obj[lines[i]];
    }
    console.log(ret);
    process.exit(0);

});

'use strict';

const readline = require('readline');

let lines = [];

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

rl.on('line', (line) => {
    lines.push(line);
});

const obj = {
        "Cube":        6,
        "Dodecahedron": 12,
        "Icosahedron": 20,
        "Octahedron":  8,
        "Tetrahedron": 4
};

rl.on('close', (cmd) => {
    let n = parseInt(lines[0]);
    let ret = 0;
    for (let i = 1; i < n + 1; ++i) {
        ret += obj[lines[i]];
    }
    console.log(ret);
    process.exit(0);

});

const readline = require('readline');

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
});

const polyhedrons = {
  Tetrahedron: 4,
  Cube: 6,
  Octahedron: 8,
  Dodecahedron: 12,
  Icosahedron:20,
}
let sum = 0, count = 0, int;

rl.on('line', (line) => {
  if (typeof int !== 'undefined' && line in polyhedrons) {
    sum += polyhedrons[line];
    if (++count === Number(int)) {
      console.log(sum);
      rl.close()
    }
  } else int = line;
});

let readline  = require('readline');
let intInput = readline.createInterface({
	input: process.stdin,
	output: process.stdout
});
let arr = [];
intInput.on('line', (line) => {
	arr.push(line)
});
intInput.on('close', () => {
	//let num = arr[0];
	let nameToSize = {
		'Tetrahedron': 4,
		'Cube': 6,
		'Octahedron': 8,
		'Dodecahedron': 12,
		'Icosahedron': 20
	}
	let sum = 0;
	for (let i = 1; i <= arr.length - 1; i++) {
		let polyhedron = arr[i];
		sum += nameToSize[polyhedron]
	}
	console.log(sum);
})

function main() {
    // write code here:
    var polyhedrons = {
        "Tetrahedron": 4,
        "Cube": 6,
        "Octahedron": 8,
        "Dodecahedron": 12,
        "Icosahedron": 20
    };
    var num = Number(stdin[0]), totalNum = 0;
    for (var i = 1; i <= num; i++) {
        totalNum += polyhedrons[stdin[i]];
    }
    console.log(totalNum);
}

const readline = require('readline');
const rl = readline.createInterface({input: process.stdin});
var stdin = [];
rl.on('line', function (line) {
    stdin.push(line);
});
rl.on('close', main);

const readline = require('readline');

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});

let i = 0;

rl.question('', (number) => {
  const shapeNames = [] ;
  rl.on('line', (shapeName) => {
    i++;
    shapeNames.push(shapeName) ;
    if (i >= parseInt(number)) {
      calFacesNum(shapeNames) ;
      rl.close();
    }
  });
});

function calFacesNum(faces) {
  let facesNumber = 0;

  for (let i = 0; i < faces.length; i++) {
    switch (faces[i]) {
      case 'Tetrahedron':
        facesNumber += 4;
        break;
      case 'Cube':
        facesNumber += 6;
        break;
      case 'Octahedron':
        facesNumber += 8;
        break;
      case 'Dodecahedron':
        facesNumber += 12;
        break;
      case 'Icosahedron':
        facesNumber += 20;
        break;
    }
  }
  console.log(facesNumber) ;
}

const readLine = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout,
});

const input = [];
readLine.on('line', line => input.push(line));

readLine.on('close', () => {
  let [count, ...geometry] = input
  count = parseInt(count, 10)
  function returnCountGeometry(el){
    switch(el){
      case 'Tetrahedron': {
        return 4
      } break;
      case 'Cube': {
        return 6
      } break;
      case 'Octahedron': {
        return 8
      } break;
      case 'Dodecahedron': {
        return 12
      } break;
      case 'Icosahedron': {
        return 20
      } break;
      default: {
        return 0
      }
    }
  }
  let _fin = 0
  for (let i = 0; i < count; i ++) {
    const el = geometry[i]
    const check = el !== '' ? true : false
    if(check) {
      const counter = returnCountGeometry(el)
      _fin += counter
    } else {
      count++
    }
  }
  console.log(_fin)
});

function onReadable(rs, bufContainer, resolve) {
  return () => {
    const chunk = rs.read();

    if (chunk) bufContainer.val = Buffer.concat([ bufContainer.val, chunk ]);

    let newLineIndex = bufContainer.val.indexOf('\n');

    if (!chunk) { newLineIndex = bufContainer.val.length; }

    if (newLineIndex !== -1) {
      const line = bufContainer.val.slice(0, newLineIndex);

      bufContainer.val = bufContainer.val.slice(newLineIndex + 1);

      return resolve(line.toString('utf-8'));
    }

    return rs.once('readable', onReadable(rs, bufContainer, resolve))
  }
}

function IO(rs, ws) {
  const bufContainer = { val: Buffer.from([]) };

  return {
    async rl() {
      const newLineIndex = bufContainer.val.indexOf('\n');

      if (newLineIndex !== -1) {
        const line = bufContainer.val.slice(0, newLineIndex);

        bufContainer.val = bufContainer.val.slice(newLineIndex + 1);

        return Promise.resolve(line.toString('utf-8'));
      }

      return new Promise(resolve => rs.once('readable', onReadable(rs, bufContainer, resolve)));
    },
    wr(str) {
      return ws.write(str);
    },
    wl(str) {
      return ws.write(str + '\n');
    }
  }
}

(async () => {
  const io = IO(process.stdin, process.stdout);

  return sol(io);
})();

async function sol({ rl, wr, wl }) {
  const grani = {
    T: 4,
    C: 6,
    O: 8,
    D: 12,
    I: 20,
  };

  const n = Number(await rl());
  let sum = 0;

  for (let i = 0; i < n; i += 1) {
    const f = (await rl())[0];
    sum += grani[f];

    if (Number.isNaN(sum)) {
        return wl(`${f} ${i}`);
    }
  }

  return wl(sum);
}

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw "ArrayIndexOutOfBoundsException ‚There is no more input";}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var N = nextInt();
  var output = 0;
  for(var i = 0; i < N; i++){
    var s = next();
    switch(s){
      case "Tetrahedron":
        output += 4;
        break;
      case "Cube":
        output += 6;
        break;
      case "Octahedron":
        output += 8;
        break;
      case "Dodecahedron":
        output += 12;
        break;
      case "Icosahedron":
        output += 20;
        break;
            }
  }
  myout(output);
}

const readLine = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout,
});

const input = [];
readLine.on('line', line => input.push(line));

readLine.on('close', () => {
  const n = +input[0];
  let k = 0;
  for (let i = 1; i <= n; i++) {
    if (input[i] === 'Tetrahedron') {
      k += 4;
    }
    else if (input[i] === 'Cube') {
      k += 6;
    }
    else if (input[i] === 'Octahedron') {
      k += 8;
    }
    else if (input[i] === 'Dodecahedron') {
      k += 12;
    }
    else if (input[i] === 'Icosahedron') {
      k += 20;
    }
  }
  console.log(k);
});

const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});
let c = 0;
let ans = 0;
const score = {
  'Tetrahedron': 4,
  'Cube': 6,
  'Octahedron': 8,
  'Dodecahedron': 12,
  'Icosahedron': 20
};

rl.on('line', (d) => {
  if (c === 0) {
    c++;
    return;
  }

  ans += score[d];

  c++;
});

rl.on('close', () => {
  console.log(ans);
});

'use strict';

let input = [];
let count_flow = {
    'Icosahedron': 20,
    'Cube': 6,
    'Tetrahedron': 4,
    'Dodecahedron': 12,
    'Octahedron': 8,
}

const RL = require('readline').createInterface({
   input : process.stdin,
   output : process.stdout
});

RL.on('line', (line) => {
    line.split(' ').map(x => input.push(x));
});

RL.on('close', () => {
    let n = parseInt(input[0]), sum = 0;
    for (let i = 1; i <= n; i++)
        sum += count_flow[input[i]];
    console.log(sum);
});

let heterolist = [];
let gayNum = 0;
let iter = 0;

const readline = require('readline');
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

function checkSum(line){
    if (line == 'Tetrahedron'){
        return 4;
    } else if (line == 'Cube'){
        return 6;
    } else if (line == 'Octahedron'){
        return 8;
    } else if (line == 'Dodecahedron'){
        return 12;
    } else if (line == 'Icosahedron'){
        return 20;
    }
};

rl.question('', (answer) => {
    sizeOfArray = answer;
    //console.log('sizeOfArray', answer);
});

rl.on('line', (line) => {
        //heterolist.push(line.split(' ', 1).map(String));
        gayNum += checkSum(line.split(' ', 1).map(String));
        iter++;
        if(iter == sizeOfArray){
            console.log(gayNum);
            process.exit(0);
        }
});

const readline = require('readline');

const rl = readline.createInterface({
  input: process.stdin
});

let sides = 0;
const sidedict = {
    "Tetrahedron": 4,
    "Cube": 6,
    "Octahedron": 8,
    "Dodecahedron": 12,
    "Icosahedron": 20
}
let c = 0;
let co;
rl.on('line', function(line){
    c++;
    if (c == 1) co = parseInt(line);
    if (c > 1) {
        sides += sidedict[line];
    }

    if ((co + 1) == c) {
        console.log(sides);
    }
});

'use strict';
process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

const readLine=()=> inputString[currentLine++];
/* ================================================
           Main Solution Starts Here
===================================================*/

const main=()=>{
	let t=+readLine()
	let sides={
		'Tetrahedron' : 4,
		'Cube' : 6,
		'Octahedron' : 8,
		'Dodecahedron' : 12,
		'Icosahedron' : 20
	}

	let totalFaces=0
	while(t--){
		let shape=readLine()
		totalFaces+=sides[shape]
	}
	console.log(totalFaces)
}

function main(input) {
    //Enter your code here
    const reference = {
        tetrahedron: 4,
        cube: 6,
        octahedron: 8,
        dodecahedron: 12,
        icosahedron: 20
    };
    let total = 0;
    const inputArray = input.split('\r\n');
    for(let i = 1; i< inputArray.length; i++) {
        if(reference.hasOwnProperty(inputArray[i].toLowerCase())) {
            total = total + reference[inputArray[i].toLowerCase()];
        }
    }
    console.log(total);
}

process.stdin.resume();
process.stdin.setEncoding("utf-8");
var stdin_input = "";

process.stdin.on("data", function (input) {
    stdin_input += input;
});

process.stdin.on("end", function () {
   main(stdin_input);
});

let fs = require('fs');

let txt = fs.readFileSync(0, "utf-8").split(/[\r\n]/).filter(data => data.length > 0);

for (let i = 0; i < txt.length; i++) {
    if (!isNaN(txt[i] * 1)) {
        let tab = [];
        for (let i1 = i + 1; i1 < i + 1 + txt[i] * 1; i1++) {
            tab.push(txt[i1]);
        }
        doit(tab);
    }

}

function doit(tab) {
    let obj = {
        Icosahedron: 20,
        Cube: 6,
        Tetrahedron: 4,
        Dodecahedron: 12,
        Octahedron: 8
    };
    let score=0;
    tab.forEach(element => {
       score+=obj[element];
    });
    console.log(score);

}

const figures = {
    Tetrahedron: 4,
    Cube: 6,
    Octahedron: 8,
    Dodecahedron: 12,
    Icosahedron: 20
};

var buffer = '';

process.stdin.setEncoding('utf8');

process.stdin.on('readable', () => {
    let chunk;
    while ((chunk = process.stdin.read()) !== null) {
        buffer += chunk;
    }
});

process.stdin.on('end', solve);

function solve() {
    buffer = buffer.split('\r\n');
    var accum = 0;
    for (let i = 1; i <= buffer[0]; i++) {
        accum += figures[buffer[i]];
    }
    process.stdout.write('' + accum);
}

const figures = {
    Tetrahedron: 4,
    Cube: 6,
    Octahedron: 8,
    Dodecahedron: 12,
    Icosahedron: 20
};

var buffer = '';

process.stdin.setEncoding('utf8');

process.stdin.on('readable', () => {
    let chunk;
    while ((chunk = process.stdin.read()) !== null) {
        buffer += chunk;
    }
});

process.stdin.on('end', () => {
    buffer = buffer.split('\r\n');
    var accum = 0;
    for (let i = 1; i <= buffer[0]; i++) {
        accum += figures[buffer[i]];
    }
    process.stdout.write('' + accum);
});

	 var n = parseInt(readline());
	var str = readline();
	var sum = 0;
     while(n){
     	if(str === "Tetrahedron") sum += 4;
     	if(str === "Cube") sum += 6;
     	if(str === "Octahedron") sum += 8;
     	if(str === "Dodecahedron") sum += 12;
     	if(str === "Icosahedron") sum += 20;
     	n--;
     }
     print(sum);

	 var n = parseInt(readline());
	var str = readline();
	var sum = 0;
     for(var i = 0; i < n; i++){
     	if(str === "Tetrahedron") sum += 4; break;
     	if(str === "Cube") sum += 6; break;
     	if(str === "Octahedron") sum += 8; break;
     	if(str === "Dodecahedron") sum += 12; break;
     	if(str === "Icosahedron") sum += 20; break;
     }
     print(sum);

	 var n = parseInt(readline());
	var str = readline();
	var sum = 0;
     for(var i = 0; i < n; i++){
     	if(str === "Tetrahedron") sum += 4;
     	if(str === "Cube") sum += 6;
     	if(str === "Octahedron") sum += 8;
     	if(str === "Dodecahedron") sum += 12;
     	if(str === "Icosahedron") sum += 20;
     }
     print(sum);
	//print(readline().includes("Tetrahedron") ? sum +=== 4:
	//("Cube") ? sum += 6 : ("Octahedron") ?sum += 8 :
	//("Dodecahedron") ? sum += 12 : ("Icosahedron") ? sum += 20;

//Tetrahedron 4
//Cube 6
//Octahedron 8
//Dodecahedron 12
//Icosahedron 20

	 var n = parseInt(readline());
	var str = readline();
	var sum = 0;
     for(var i = 0; i <= n; i++){
     	if(str === "Tetrahedron") sum += 4;
     	if(str === "Cube") sum += 6;
     	if(str === "Octahedron") sum += 8;
     	if(str === "Dodecahedron") sum += 12;
     	if(str === "Icosahedron") sum += 20;
     }
     print(sum);

	 var n = parseInt(readline());
	var sum = 0;
     for(var i = 0; i < n; i++){
     	var str = readline();
     	if(str === "Tetrahedron") sum += 4;
     	if(str === "Cube") sum += 6;
     	if(str === "Octahedron") sum += 8;
     	if(str === "Dodecahedron") sum += 12;
     	if(str === "Icosahedron") sum += 20;
     	n --;
     }
     print(sum);

	 var n = parseInt(readline());
	var sum = 0;
	var str = readline();
     while(n){
     	if(str === "Tetrahedron") sum += 4;
     	if(str === "Cube") sum += 6;
     	if(str === "Octahedron") sum += 8;
     	if(str === "Dodecahedron") sum += 12;
     	if(str === "Icosahedron") sum += 20;
     	n --;
     }
     print(sum);

var n = Number(readline());
var arr = [];

for(var i = 0; i <= n; i++) {
    arr.push(readline());
}

var obj = {
    'Tetrahedron': 4,
    'Cube': 6,
    'Octahedron': 8,
    'Dodecahedron': 12,
    'Icosahedron': 20,
}

var result = 0;
arr.map(item => result += obj[item])

print(result)

var n = readline();
var arr = [];
for(var i = 0; i <= n; i++) {
    arr.push(readline());
}

var obj = {
    'Tetrahedron': 4,
    'Cube': 6,
    'Octahedron': 8,
    'Dodecahedron': 12,
    'Icosahedron': 20,
}

var result = 0;
arr.map(i => result += obj[i])

print(result)

var n = Number(readline());
var arr = [];

for(var i = 0; i < n; i++) {
    arr.push(readline());
}

var obj = {
    'Tetrahedron': 4,
    'Cube': 6,
    'Octahedron': 8,
    'Dodecahedron': 12,
    'Icosahedron': 20
}

var result = 0;
arr.map(item => result += obj[item])

print(arr)

var n = readline();
var arr = [];
for(var i = 0; i <= n; i++) {
    arr.push(readline());
}

var obj = {
    'Tetrahedron': 4,
    'Cube': 6,
    'Octahedron': 8,
    'Dodecahedron': 12,
    'Icosahedron': 20,
}

var result = 0;
arr.map(item => result += obj[item])

print(result)

var n = readline();
var arr = [];
for(var i = 0; i <= n; i++) {
    var el = readline();
    arr.push(el);
}

var obj = {
    'Tetrahedron': 4,
    'Cube': 6,
    'Octahedron': 8,
    'Dodecahedron': 12,
    'Icosahedron': 20,
}

var result = 0;
arr.map(item => result += obj[item])

print(result)

var a = readline(), b, c = 0;

for (; a; a--) {
  b = readline()[0];
  if (b === 'C') c += 6; continue;
  if (b === 'D') c += 12; continue;
  if (b === 'I') c += 20; continue;
  if (b === 'O') c += 8; continue;
  if (b === 'T') c += 4; continue;
}

print(c);

var a = readline(), b, c = 0;

for (; a > 0; a--) {
  b = readline()[0];
  if (b === 'C') c += 6; continue;
  if (b === 'D') c += 12; continue;
  if (b === 'I') c += 20; continue;
  if (b === 'O') c += 8; continue;
  if (b === 'T') c += 4; continue;
}

print(c);

var numbers = readline();
var a = numbers[0];
 var number = readline().split("\n");
var b = 0;
for(var i=0; i<a; i++){
    if(number[i]==='Tetrahedron') {b=b+4}
    if(number[i]==='Cube'){b=b+6}
    if(number[i]==='Octahedron'){b=b+8}
    if(number[i]==='Dodecahedron'){b=b+12}
    if(number[i]==='Icosahedron'){b=b+20}
}
print(b)

var numbers = readline();
var a = numbers[0];
var number = []
var e=[];
var b = 0;

for(var i=0; i<a; i++){
    number.push(readline())
    if(number[i]==='Tetrahedron') {b=b+4}
    if(number[i]==='Cube'){b=b+6}
    if(number[i]==='Octahedron'){b=b+8}
    if(number[i]==='Dodecahedron'){b=b+12}
    if(number[i]==='Icosahedron'){b=b+20}
}

print(b)

var numbers = readline();
var number = readline().split(' ');
var a = numbers[0];
var b = 0;
for(var i=0; i<a; i++){
    number[i];
    if(number[i]==='Tetrahedron') {b=b+4}
    if(number[i]==='Cube'){b=b+6}
    if(number[i]==='Octahedron'){b=b+8}
    if(number[i]==='Dodecahedron'){b=b+12}
    if(number[i]==='Icosahedron'){b=b+20}
}
print(b)

var array = {"Tetrahedron": 3, "Cube": 6, "Octahedron": 8, "Dodecahedron": 12, "Icosahedron": 20};
var n = parseInt(readline());

var sum=0;
for (var i = 0; i < n; i++) {
    var key=readline();
    sum+=array[key];
}

print(sum);

var limit = parseInt(readline());
var map = {}
map['Icosahedron'] = 20;
map['Dodecahedron'] = 12;
map['Octahedron'] = 8;
map['Cube'] = 6;
map['Tetrahedron'] = 4;
var sum = 0;
for (var i = 0; i < limit; i++) {
  sum += parseInt(readline());
}
print(sum);

var limit = parseInt(readline());
var map = {}
map['Icosahedron'] = 20;
map['Dodecahedron'] = 12;
map['Octahedron'] = 8;
map['Cube'] = 6;
map['Tetrahedron'] = 4;
var sum = 0;
print(limit);

const readline = require('readline');

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});

let i = 0;

rl.question('Number of inputs : ', (number) => {
  const shapeNames = [] ;
  rl.on('line', (shapeName) => {
    i++;
    shapeNames.push(shapeName) ;
    if (i >= parseInt(number)) {
      calFacesNum(shapeNames) ;
      rl.close();
    }
  });
});

function calFacesNum(faces) {
  let facesNumber = 0;
  for (let i = 0; i < faces.length; i++) {

    switch (faces[i]) {
      case 'Tetrahedron':
        facesNumber += 4;
        break;
      case 'Cube':
        console.log('hello amir is here') ;
        facesNumber += 6;
        break;
      case 'Octahedron':
        facesNumber += 8;
        break;
      case 'Dodecahedron':
        facesNumber += 12;
        break;
      case 'Icosahedron':
        facesNumber += 20;
        break;
    }
  }
  console.log(facesNumber) ;
}

const readLine = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout,
});

const input = [];
readLine.on('line', line => input.push(line));

readLine.on('close', () => {
  let [count, ...geometry] = input
  count = parseInt(count, 10)
  function returnCountGeometry(el){
    switch(el){
      case 'Tetrahedron': {
        return 4
      } break;
      case 'Cube': {
        return 6
      } break;
      case 'Octahedron': {
        return 8
      } break;
      case 'Dodecahedron': {
        return 12
      } break;
      case 'Icosahedron': {
        return 20
      } break;
      default: {
        return 0
      }
    }
  }
  let _fin = 0
  for (let i = 0; i < count; i ++) {
    const el = geometry[i]
    const counter = returnCountGeometry(el)
    _fin += counter
  }
  console.log(_fin)
});

function IO(rs, ws, readSize = 1024) {
  let buffer = Buffer.from([]);
  let nextLineIndex;
  let line;
  let chunk;

  return {
    rl() {
      while(true) {
        newLineIndex = buffer.indexOf('\n');

        if (newLineIndex === -1 && rs.readableLength === 0) {
          newLineIndex = buffer.length;
        }

        if (newLineIndex !== -1) {
          line = buffer.slice(0, newLineIndex);

          buffer = buffer.slice(newLineIndex + 1);

          return line.toString('utf-8');
        }

        if (rs.readableLength === 0) {
          return null
        }

        chunk = rs.read(Math.min(readSize, rs.readableLength));

        if (!chunk) { return null; }

        buffer = Buffer.concat([ buffer, chunk ]);
      }
    },

    wr(str) {
      return ws.write(str);
    },

    wl(str) {
      return ws.write(str + '\n');
    }
  };
}

process.stdin.once('readable', () => sol(IO(process.stdin, process.stdout)));

function sol({ rl, wr, wl }) {
  const grani = {
    T: 4,
    C: 6,
    O: 8,
    D: 12,
    I: 20,
  };

  const n = Number(rl());
  let sum = 0;

  for (let i = 0; i < n; i += 1) {
    const f = rl()[0];
    sum += grani[f];
  }

  return wl(sum);
}

// Nothing special here, just self-made reading api
class Reader{constructor(a,b){this.stream=a,this.stream.setEncoding("utf8"),this.bufSize=b||1024,this.buf="",this.streamEnded=!1}onReadable(a){return()=>{for(let b;-1===(b=this.buf.indexOf("\n"));){if(0===this.stream.readableLength)return this.stream.read(),void this.stream.once("readable",this.onReadable(a));this.buf+=this.stream.read(Math.min(this.bufSize,this.stream.readableLength))}this.stream.removeAllListeners("end"),this.readline().then(a)}}onEnd(a){return()=>{this.streamEnded=!0,this.readline().then(a)}}readline(){return new Promise(a=>{const b=this.buf.indexOf("\n");if(-1===b&&!this.streamEnded)this.stream.once("readable",this.onReadable(a)),this.stream.once("end",this.onEnd(a));else{let c;this.streamEnded?(c=this.buf,this.buf=""):(c=this.buf.substring(0,b),this.buf=this.buf.substring(b+1)),a(c)}})}}(async()=>{const a=new Reader(process.stdin);await solution(a.readline.bind(a),console.log.bind(this))})();

async function solution(rl, wl) {
  const grani = {
    T: 4,
    C: 6,
    O: 8,
    D: 12,
    I: 20,
  };
  const n = parseInt((await rl()), 10);
  let sum = 0;
  for (let i = 0; i < n; i += 1) {
    const f = (await rl())[0];
    sum += grani[f];
  }
    wl(sum);
}

function IO(rs, ws, readSize = 1024) {
    let buffer = Buffer.from([]);
    let nextLineIndex;
    let line;
    let chunk;

    return {
      rl() {
        while(true) {
          newLineIndex = buffer.indexOf('\n');

          if (newLineIndex === -1 && rs.readableLength === 0) {
            newLineIndex = buffer.length;
          }

          if (newLineIndex !== -1) {
            line = buffer.slice(0, newLineIndex);

            buffer = buffer.slice(newLineIndex + 1);

            return line.toString('utf-8');
          }

          if (rs.readableLength === 0) {
            return null
          }

          chunk = rs.read(Math.min(readSize, rs.readableLength));

          if (!chunk) { return null; }

          buffer = Buffer.concat([ buffer, chunk ]);
        }
      },

      wr(str) {
        return ws.write(str);
      },

      wl(str) {
        return ws.write(str + '\n');
      }
    };
  }

  process.stdin.once('readable', () => sol(IO(process.stdin, process.stdout, 32)));

  function sol({ rl, wr, wl }) {
    const grani = {
      T: 4,
      C: 6,
      O: 8,
      D: 12,
      I: 20,
    };

    const n = Number(rl());
    let sum = 0;

    for (let i = 0; i < n; i += 1) {
      const f = rl()[0];
      sum += grani[f];

      if (Number.isNaN(sum)) {
          return wl(`${f} ${i}`);
      }
    }

    return wl(sum);
  }

function IO(rs, ws, readSize = 1024) {
    let buffer = Buffer.from([]);
    let nextLineIndex;
    let line;
    let chunk;

    return {
      rl() {
        while(true) {
          newLineIndex = buffer.indexOf('\n');

          if (newLineIndex === -1 && rs.readableLength === 0) {
            newLineIndex = buffer.length;
          }

          if (newLineIndex !== -1) {
            line = buffer.slice(0, newLineIndex);

            buffer = buffer.slice(newLineIndex + 1);

            return line.toString('utf-8');
          }

          if (rs.readableLength === 0) {
            return null
          }

          chunk = rs.read(Math.min(readSize, rs.readableLength));

          if (!chunk) { return null; }

          buffer = Buffer.concat([ buffer, chunk ]);
        }
      },

      wr(str) {
        return ws.write(str);
      },

      wl(str) {
        return ws.write(str + '\n');
      }
    };
  }

  process.stdin.once('readable', () => sol(IO(process.stdin, process.stdout, 32)));

  function sol({ rl, wr, wl }) {
    const grani = {
      T: 4,
      C: 6,
      O: 8,
      D: 12,
      I: 20,
    };

    const n = Number(rl());
    let sum = 0;

    for (let i = 0; i < n; i += 1) {
      const f = rl()[0];
      sum += grani[f];

      if (Number.isNaN(sum)) {
          return wl(f);
      }
    }

    return wl(sum);
  }

'use strict';

let input = [];
let count_flow = {
    'Icosahedron': 20,
    'Cube': 6,
    'Tetrahedron': 4,
    'Dodecahedron': 12,
    'Octahedron': 8,
}

const RL = require('readline').createInterface({
   input : process.stdin,
   output : process.stdout
});

RL.on('line', (line) => {
    line.split(' ').map(x => input.push(x));
});

RL.on('close', () => {
    let n = parseInt(input[0]), sum = 0;
    console.log(input);
    for (let i = 1; i <= n; i++)
        sum += count_flow[input[i]];
    console.log(sum);
});

let heterolist = [];
let gayNum = 0;
let iter = 0;

const readline = require('readline');
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

function checkSum(line){
    if (line == 'Tetrahedron'){
        return 4;
    } else if (line == 'Cube'){
        return 6;
    } else if (line == 'Octahedron'){
        return 8;
    } else if (line == 'Dodecahedron'){
        return 12;
    } else if (line == 'Icosahedron'){
        return 20;
    }
};

rl.question('', (answer) => {
    sizeOfArray = answer;
    console.log('sizeOfArray', answer);
});

rl.on('line', (line) => {
        //heterolist.push(line.split(' ', 1).map(String));
        gayNum += checkSum(line.split(' ', 1).map(String));
        iter++;
        if(iter == sizeOfArray){
            console.log(gayNum);
            process.exit(0);
        }
});

function main(input) {
    //Enter your code here
    const reference = {
        Tetrahedron: 4,
        Cube: 6,
        Octahedron: 8,
        Dodecahedron: 12,
        Icosahedron: 20
    };
    let total = 0;

    const inputArray = input.split("\n");
    for(let i = 1; i< inputArray.length; i++) {
        total = total + reference[inputArray[i]];
    }
    console.log(total);
}

process.stdin.resume();
process.stdin.setEncoding("utf-8");
var stdin_input = "";

process.stdin.on("data", function (input) {
    stdin_input += input;
});

process.stdin.on("end", function () {
   main(stdin_input);
});

function main(input) {
    //Enter your code here
    const reference = {
        tetrahedron: 4,
        cube: 6,
        octahedron: 8,
        dodecahedron: 12,
        icosahedron: 20
    };
    let total = 0;
    const inputArray = input.split('\r\n');
    console.log(inputArray)
    for(let i = 1; i< inputArray.length; i++) {
        total = total + reference[inputArray[i].toLowerCase()];
    }
    console.log(total);
}

process.stdin.resume();
process.stdin.setEncoding("utf-8");
var stdin_input = "";

process.stdin.on("data", function (input) {
    stdin_input += input;
});

process.stdin.on("end", function () {
   main(stdin_input);
});

function main(input) {
    //Enter your code here
    const reference = {
        Tetrahedron: 4,
        Cube: 6,
        Octahedron: 8,
        Dodecahedron: 12,
        Icosahedron: 20
    };
    let total = 0;
    const inputArray = input.split('\r\n');
    for(let i = 1; i< inputArray.length; i++) {
        total = total + reference[inputArray[i]];
    }
    console.log(total);
}

process.stdin.resume();
process.stdin.setEncoding("utf-8");
var stdin_input = "";

process.stdin.on("data", function (input) {
    stdin_input += input;
});

process.stdin.on("end", function () {
   main(stdin_input);
});

function main(input) {
    //Enter your code here
    const reference = {
        Tetrahedron: 4,
        Cube: 6,
        Octahedron: 8,
        Dodecahedron: 12,
        Icosahedron: 20
    };
    let total = 0;

    const inputArray = input.split("\n");
    console.log(inputArray);
    for(let i = 1; i< inputArray.length; i++) {
        reference[inputArray[i]];
        total = total + reference[inputArray[i]];
    }
    console.log(total);
}

process.stdin.resume();
process.stdin.setEncoding("utf-8");
var stdin_input = "";

process.stdin.on("data", function (input) {
    stdin_input += input;
});

process.stdin.on("end", function () {
   main(stdin_input);
});

function main(input) {
    //Enter your code here
    const reference = {
        Tetrahedron: 4,
        Cube: 6,
        Octahedron: 8,
        Dodecahedron: 12,
        Icosahedron: 20
    };
    let total = 0;
    const inputArray = input.split("\r\n");
    for(let i = 1; i< inputArray.length; i++) {
        total = total + reference[inputArray[i]];
    }
    console.log(total);
}

process.stdin.resume();
process.stdin.setEncoding("utf-8");
var stdin_input = "";

process.stdin.on("data", function (input) {
    stdin_input += input;
});

process.stdin.on("end", function () {
   main(stdin_input);
});

const names = {
    Tetrahedron: 4,
    Cube: 6,
    Octahedron: 8,
    Dodecahedron: 12,
    Icosahedron: 20
};

process.stdin.on('data', (input) => {
    process.stdout.write(input.toString().split('\n').slice(1).map((x) => names[x.trim()]).reduce((x, y) => x + y).toString());
});

const names = {
    Tetrahedron: 4,
    Cube: 6,
    Octahedron: 8,
    Dodecahedron: 12,
    Icosahedron: 20
};

process.stdin.on('data', (input) => {
    process.stdout.write(input.toString().trim().split('\n').slice(1).map((x) => names[x.trim()]).reduce((x, y) => x + y).toString());
});

var input='';

process.stdin.on('data',(givenInput)=>{
    input+=givenInput;
})

process.stdin.on('end',()=>{
    main(input);
})

const main=(input)=>{

    const n=Number(input.split('\r\n')[0]);
    let strArr=input.split('\r\n');

    let num,total=0;

    for(let i=1;i<strArr.length;i++){

        str=strArr[i];

        switch(str){
            case 'Tetrahedron': num=4; break;
            case 'Cube': num=6; break;
            case 'Octahedron': num=8 ; break;
            case 'Dodecahedron': num=12 ; break;
            case 'Icosahedron': num=20 ; break;
        }

        total+=num;
    }

    console.log(total);

}

var input='';

process.stdin.on('data',(givenInput)=>{
    input+=givenInput;
})

process.stdin.on('end',()=>{
    main(input);
})

const main=()=>{

    const n=Number(input.split('\r\n')[0]);
    let strArr=input.split('\r\n');

    let num,total=0;

    for(let i=1;i<strArr.length;i++){

        str=strArr[i];

        switch(str){
            case 'Tetrahedron': num=4; break;
            case 'Cube': num=6; break;
            case 'Octahedron': num=8 ; break;
            case 'Dodecahedron': num=12 ; break;
            case 'Icosahedron': num=20 ; break;
        }

        total+=num;
    }

    console.log(total);

}

var result = solution(readline().split(' '));
print(result);

// End of interface

function solution(c) {
	var n = parseInt(c[0]);
	var arr = c.slice(1);

	var main = function(n, k){
		var res = 0;
		for(i = 0; i < n; i++){
			switch (k[i]) {
				case 'Tetrahedron':
					res = res + 4;
					break;
				case 'Cube':
					res = res + 6;
					break;
				case 'Octahedron':
					res = res + 8;
					break;
				case 'Dodecahedron':
					res = res + 12;
					break;
				case 'Icosahedron':
					res = res + 20;
					break;
			}
		}
		return res;
	};

	return main(n, arr);
}

var n = parseInt(readline());
var log = {Tetrahedron: 4, Cube: 6, Octahedron: 8, Dodecahedron: 12, Icosahedron:20};
var sideCount = 0;
while (n--) {
	sideCount += sideCount[readline()];
}
print(sideCount);

var number=readline();
var count=0;
var figure={
    "Tetrahedron":4,
    "Cube":6,
    "Octahedron":8,
    "Dodecahedron":12,
    "Icosahedron":20
}

for(var i=0;i<number;i++){
    var figuresName=readline();
    count+=figure[figuresName];
    print(figure[figuresName])
}
print(count);