#include #define FOR(i, n) for(int i = 0; i < (n); ++i) #define REP(i, a, b) for(int i = (a); i < (b); ++i) #define TRAV(i, a) for(auto & i : (a)) #define SZ(x) ((int)(x).size()) #define X first #define Y second #define MP std::make_pair #define PR std::pair typedef long long ll; typedef std::pair PII; typedef std::vector VI; int main(){ std::ios_base::sync_with_stdio(false); std::cin.tie(0); std::string xd; ll price = 0; while(std::cin >> xd){ if(xd[0] == '|'){ price += 42ll*SZ(xd); }else{ std::string a = ""; int pos = 0; while(xd[pos] != ','){ a.push_back(xd[pos]); pos++; } pos++; int ile = std::stoi(a); price += 1ll*ile*std::max(1, (SZ(xd)-pos-1)); } } while(price % 10 != 0) price++; std::cout << price; return 0; }