2023-12-03 21:49:21 -08:00
|
|
|
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
ios::sync_with_stdio(0);
|
|
|
|
cin.tie(0);
|
|
|
|
|
2023-12-04 11:46:32 -08:00
|
|
|
vector<int> counts, copies;
|
2023-12-03 21:49:21 -08:00
|
|
|
|
|
|
|
string line;
|
|
|
|
while (getline(cin, line) && !line.empty()) {
|
|
|
|
int start = line.find(':');
|
|
|
|
int bar = line.find('|');
|
|
|
|
string left = line.substr(start + 2, bar - start - 3);
|
|
|
|
string right = line.substr(bar + 2);
|
|
|
|
istringstream lss(left), rss(right);
|
2023-12-04 11:46:32 -08:00
|
|
|
set<int> ls;
|
|
|
|
int count = 0;
|
2023-12-03 21:49:21 -08:00
|
|
|
while (!lss.eof()) {
|
|
|
|
int n;
|
|
|
|
lss >> n;
|
2023-12-04 11:46:32 -08:00
|
|
|
ls.insert(n);
|
2023-12-03 21:49:21 -08:00
|
|
|
}
|
2023-12-04 11:46:32 -08:00
|
|
|
while (!rss.eof()) {
|
|
|
|
int n;
|
|
|
|
rss >> n;
|
|
|
|
if (ls.find(n) != ls.end())
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
counts.push_back(count);
|
|
|
|
copies.push_back(1);
|
2023-12-03 21:49:21 -08:00
|
|
|
}
|
2023-12-04 11:46:32 -08:00
|
|
|
int ret = 0;
|
|
|
|
for (int cn = 0; cn < counts.size(); cn++) {
|
2023-12-03 21:49:21 -08:00
|
|
|
ret += copies[cn];
|
|
|
|
int n = cn;
|
2023-12-04 11:46:32 -08:00
|
|
|
for (int i = 0; i < counts[cn]; i++) {
|
|
|
|
if (++n == copies.size())
|
|
|
|
break;
|
|
|
|
copies[n] += copies[cn];
|
2023-12-03 21:49:21 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
cout << ret << '\n';
|
|
|
|
}
|