package testa;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner point = new Scanner(System.in);
while (point.hasNextLine()) {
String numStr = point.nextLine();
char[] outputChar = replaceZero(numStr).toCharArray();
int[] tempList = new int[outputChar.length];
// 处理中间结果
int j = solveMediumResult(outputChar, tempList);
int[] list = new int[j + 1];
for (int item = 0; item <= j; item++) list[item] = tempList[item];
// 快速排序
fastSorted(list, 0, list.length - 1);
for (int k = 0; k < list.length - 1; k++) System.out.print(list[k] + " ");
System.out.println(list[list.length - 1]);
}
}
/**
* 替换0
*
* @param inputStr
* @return
*/
public static String replaceZero(String inputStr) {
char[] charList = inputStr.toCharArray();
inputStr = "";
for (int i = 0; i < charList.length; i = i + 1) {
if (charList[i] == '5') {
if (i > 0 && charList[i - 1] == '5') {
continue;
}
inputStr = inputStr + " ";
} else if (i > 0 && charList[i] == '0' && charList[i - 1] == '5') {
while (i < charList.length - 1 && charList[i + 1] == '0') { i++;}
inputStr = inputStr + charList[i];
} else if (i == 0 && charList[i] == '0') {
while (i < charList.length - 1 && charList[i + 1] == '0') { i++;}
inputStr = inputStr + charList[i];
} else {
inputStr = inputStr + charList[i];
}
}
return inputStr;
}
/**
* 快速排序
*
* @param list
*/
public static void fastSorted(int[] list, int i, int j) {
if (i >= j) {
return;
}
int needToSortLen = j;
int referIndex = i;
while (i != j) {
while (list[referIndex] <= list[j] && j > i) { j--;}
while (list[referIndex] >= list[i] && i < j) { i++;}
int temp = list[j];
list[j] = list[i];
list[i] = temp;
}
int tempReferValue = list[referIndex];
list[referIndex] = list[i];
list[i] = tempReferValue;
fastSorted(list, referIndex, i - 1);
fastSorted(list, i + 1, needToSortLen);
}
/**
*
* @Name: solveMediumResult
* @Description: 处理中间结果
* @param @param outputChar
* @param @param tempList
* @param @return
* @return int
* @throws
*/
private static int solveMediumResult(char[] outputChar, int[] tempList) {
String tempStr = "";
int j = 0;
// convert char to int
for (int i = 0; i < outputChar.length; i++) {
if (outputChar[i] == ' ') {
if (i == outputChar.length - 1) {
break;
}
if (!tempStr.equals("")) {
tempList[j] = Integer.parseInt(tempStr);
j++;
tempStr = "";
}
continue;
}
tempStr = tempStr + outputChar[i];
}
tempList[j] = Integer.parseInt(tempStr);
return j;
}
}