#include<bits/stdc++.h>
using namespace std;
#define int long long
int Random(int x)
{
return rand() % x;
}
signed main()
{
srand(time(0));
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
string s;
getline(cin, s);
int End = s.size();
s = " " + s + " ";
int pos = 0;
int n;
cin >> n;
for(int i = 1; i <= n; i++)
{
int x;
cin >> x;
pos += x;
if(pos > End)
pos = End;
if(s[pos] == '>')
{
if(s[pos + 1] == '>' && s[pos + 2] == '>')
{
while(s[pos] == '>')
{
pos++;
}
if(pos > End)
pos = End;
}
}
else if(s[pos] == '*')
{
if(s[pos + 1] == '*' && s[pos + 2] == '*')
{
int k = 0;
while(s[pos + k] == '*')
{
k++;
}
pos -= k;
if(pos < 1)
pos = 1;
}
}
}
cout << pos << " " << End - pos << endl;
return 0;
}