import java.util.Stack;
public class TwoStack {
public static Stack<Integer> sort(Stack<Integer> s){
Stack<Integer> s2 = new Stack<Integer>();
while(!s.isEmpty()){
int temp = s.pop();
while(!s2.isEmpty() && s2.peek()<temp){
s.push(s2.pop());
}
s2.push(temp);
}
return s2;
}
public static void main(String args[]){
Stack<Integer> s = new Stack<Integer>();
s.push(2);
s.push(7);
s.push(1);
s.push(3);
s.push(5);
//TwoStack twoStack = new TwoStack();
System.out.println(TwoStack.sort(s));
}
}