#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
using namespace __gnu_pbds;
using namespace std;
signed main()
{
queue<char>q;
int n;
cin>>n;
for(int i=1;i<=n;i++)
{
string s;
cin>>s;
if(s!="<bs>")q.push(s[0]);
else if(!q.empty()) q.pop();
}
while(!q.empty())
{
cout<<q.front();
q.pop();
}
return 0;
}