//用一点写一点,不够,赋值100并换行
#include<iostream>
#include<stdio.h>
#include<vector>
#include<map>
using namespace std;
int main(void)
{
map<char,int> mp;
for(char c = 'a';c<='z';c++)
cin>>mp[c];
string str;
cin>>str;
int wid=100;
int row = 1;
for(char c:str)
{
int cost = mp[c];
if(wid < cost)
{
row++;
wid=100;
}
wid-=cost;
}
cout<<row<<" "<<100-wid;
return 0;
}