using System;
using System.Collections.Generic;
using System.Linq;
namespace task29735221
{
class Program
{
static void Main(string[] args)
{
string input = Console.ReadLine();
LinkedList output = new LinkedList();
foreach (var character in input)
{
if (character == '#')
{ if (output.Any()) output.RemoveLast(); }
else if (character == '$')
{ if (output.Any()) output.AddLast(output.Last.Value); }
else
output.AddLast(character);
}
Console.WriteLine(String.Join("", output));
}
}
}