#include<iostream>
#include<string>
#include<fstream>
#include<algorithm>
#include<vector>
#include<iterator>
#include<numeric>
using namespace std;
struct Record {
string surname;
string dbname;
int salary;
};
istream& operator>>(istream& is, Record& r)
{
is >> r.surname;
is.ignore(6, '|');
is >> r.dbname;
is.ignore(6, '|');
is.ignore(6, '*');
is >> r.salary;
return is;
}
ostream& operator<<(ostream& os, const Record& r)
{
os << r.surname << " "
<< r.dbname << " "
<< r.salary;
return os;
}
int main()
{
vector<Record> database;
if(ifstream file("databasename.db"); file)
{
copy(istream_iterator<Record>(file), {}, back_inserter(database));
}
string db;
cin >> db;
int acc = accumulate(database.begin(), database.end(), 0, [&](int init, Record const& rec){
return (db == rec.dbname) ? init + rec.salary : init;
});
cout << db << ": " << acc;
//copy(database.begin(), database.end(), ostream_iterator<Record>(cout, "\n"));
}