import java.util.*;
import java.io.*;
class Main {
public static void main(String args[]) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb = new StringBuilder();
Stack<Character> stack = new Stack<Character>();
String s = br.readLine();
int len = s.length();
boolean flag = false;
for(int i = 0 ; i < len ; i ++) {
if(s.charAt(i) == '<') {
while(!stack.isEmpty()) {
sb.append(stack.pop());
}
sb.append('<');
while(s.charAt(i++) != '>') {
sb.append(s.charAt(i));
}
i--;
}else if(s.charAt(i) == ' '){
while(!stack.isEmpty()) {
sb.append(stack.pop());
}
sb.append(" ");
}else {
stack.push(s.charAt(i));
}
}
while(!stack.isEmpty()) {
sb.append(stack.pop());
}
System.out.println(sb);
}
}
개똥같은 코드를 짰다고 생각했는데 예상외로 순위권이었다.