#include<iostream>
#include<vector>
#include<string>
#include<cstdlib>

using namespace std;

int main(){
	string s;
	int price = 42;
	long long finalbill = 0;
	while(getline(cin, s)){
		if(s.at(0) != '|'){
			size_t b = s.find_first_of(',');	
			long num = atoll(s.substr(0, b).c_str());
			b = s.find_first_of('|');
			if(b == string::npos){
				finalbill += num;
			}else{
				size_t e = s.find_last_of('|');
				finalbill += (e - b + 1) * num;
			}
		}else{
			size_t b = s.find_first_of('|');
			size_t e = s.find_last_of('|');
			finalbill += (e - b + 1) * price;
		}
	}	

	int r = finalbill % 10;
	if(r != 0){
		if(r >= 5)
			finalbill += 10-r;
		else
			finalbill -= r;
	}

	cout << finalbill << ",-\n";

	return 0;
}

