package me ;
import java.util.LinkedList;
public class MyStack{
private LinkedList<Character> stack=new LinkedList<Character>() ;
public Character pop(){
return stack.pop() ;
}
public void push(Character e){
stack.push(e) ;
}
public Character peek(){
return stack.peek() ;
}
public boolean isEmpty(){
return stack.isEmpty() ;
}
public int size(){
return stack.size() ;
}
public void run(String str){
for(int i=0;i<str.length();i++){
if(str.charAt(i)=='+'){
stack.push(str.charAt(i+1) ) ;
continue ;
}
else if(str.charAt(i)=='-'){
System.out.print(stack.pop());
continue ;
}
}
}
public static void main(String[]agrs)
{
MyStack m=new MyStack() ;
String str="+a+b+c---+e+r+t---+a-+i-+5+7-+6-" ;
m.run(str) ;
}
}