#include using namespace std; int main(){ int n; cin >> n; int t; string s; int wordcount; int type; int good = 0; int bad = 0; for(int i = 0; i < n; i++){ cin >> t >> s; wordcount = s.length(); type = 12 * t / 1000; if(wordcount <= type){ good += wordcount; }else{ good += type; bad += wordcount - type; } } cout << good << " " << bad << endl; }