mad_string = input().replace("[", "(").replace("{", "(").replace("]", ")").replace("}", ")")
output_list = []
while mad_string:
# find last open bracket
last_open = len(mad_string) - mad_string[::-1].index("(")
# find first close bracket
first_closed = mad_string.index(")")
# add slice (without brackets) to output, remove slice (including brackets)
output_list.append(mad_string[last_open:first_closed])
mad_string = mad_string[:last_open-1] + mad_string[first_closed+1:]
# remove spaces between items for consistency
output_list = [x.strip() for x in output_list]
# print items adding one space between each
print(" ".join(output_list))
bWFkX3N0cmluZyA9IGlucHV0KCkucmVwbGFjZSgiWyIsICIoIikucmVwbGFjZSgieyIsICIoIikucmVwbGFjZSgiXSIsICIpIikucmVwbGFjZSgifSIsICIpIikKb3V0cHV0X2xpc3QgPSBbXQoKd2hpbGUgbWFkX3N0cmluZzoKICAgICMgZmluZCBsYXN0IG9wZW4gYnJhY2tldAogICAgbGFzdF9vcGVuID0gbGVuKG1hZF9zdHJpbmcpIC0gbWFkX3N0cmluZ1s6Oi0xXS5pbmRleCgiKCIpCiAgICAKICAgICMgZmluZCBmaXJzdCBjbG9zZSBicmFja2V0CiAgICBmaXJzdF9jbG9zZWQgPSBtYWRfc3RyaW5nLmluZGV4KCIpIikKICAgIAogICAgIyBhZGQgc2xpY2UgKHdpdGhvdXQgYnJhY2tldHMpIHRvIG91dHB1dCwgcmVtb3ZlIHNsaWNlIChpbmNsdWRpbmcgYnJhY2tldHMpICAgIAogICAgb3V0cHV0X2xpc3QuYXBwZW5kKG1hZF9zdHJpbmdbbGFzdF9vcGVuOmZpcnN0X2Nsb3NlZF0pCiAgICBtYWRfc3RyaW5nID0gbWFkX3N0cmluZ1s6bGFzdF9vcGVuLTFdICsgbWFkX3N0cmluZ1tmaXJzdF9jbG9zZWQrMTpdCgojIHJlbW92ZSBzcGFjZXMgYmV0d2VlbiBpdGVtcyBmb3IgY29uc2lzdGVuY3kKb3V0cHV0X2xpc3QgPSBbeC5zdHJpcCgpIGZvciB4IGluIG91dHB1dF9saXN0XQoKIyBwcmludCBpdGVtcyBhZGRpbmcgb25lIHNwYWNlIGJldHdlZW4gZWFjaApwcmludCgiICIuam9pbihvdXRwdXRfbGlzdCkp