#include <iostream>
#include <cstdio>
#include <string>
#include <list>
using namespace std;
//英语 抄博友程序 输入巧妙 list使用 字符串s=s+c会超时 背
int main()
{
//freopen("1885.txt","r",stdin);
string s;
list<string> table;
list<string>::iterator it;
char c;
while((c=getchar())!=-1)s+=c;//抄博友程序 巧妙 s=s+c会超时
int pos=s.find_last_of("0");//抄博友程序 数字中可能出现0 巧妙
s.erase(pos,s.size());
for(int i=0; i<s.size(); i++)
{
if('0'<=s[i] && s[i]<='9')
{
int num=0;
while('0'<=s[i] && s[i]<='9')
{
num=num*10+s[i]-'0';
i++;
}
i--;//抄博友程序
int pos=0;
it=table.begin();
while(++pos!=num)//抄博友程序
{
it++;
}
string temp=*it;
cout<<temp;
table.erase(it);//抄博友程序
table.push_front(temp);
}else if(('a'<=s[i] && s[i]<='z') ||('A'<=s[i] && s[i]<='Z'))
{
string temp;
while(('a'<=s[i] && s[i]<='z') ||('A'<=s[i] && s[i]<='Z'))
{
temp+=s[i++];//temp=temp+s[i++]超时
}
i--;
table.push_front(temp);
cout<<temp;
}else
{
cout<<s[i];
}
}
return 0;
}