#include <iostream>
#include <sstream>
#include <string>
#include <vector>
int main()
{
int n;
std::cin >> n;
std::cin.ignore();
std::string keys;
std::getline(std::cin, keys);
std::istringstream iss(keys);
std::string key;
std::string result;
for (int i = 0; i < n; ++i)
{
iss >> key;
if (key == "<bs>" && !result.empty())
{
result.pop_back();
}
else if (key.length() == 1 && key >= "a" && key <= "z")
{
result += key;
}
}
std::cout << result << std::endl;
return 0;
}