

 
import java.util.Scanner;

import java.util.*;
import java.util.Arrays;
 
 
class Main {
    
    public static void main(String[] args) {
    
        // 控制台输入
        Scanner scanner = new Scanner(System.in);
        String numsStr = scanner.nextLine();
      
        int[] nums = new int[]{};
        // 解析字符串，构造数组
        numsStr = numsStr.replaceAll(" ","");
        
        if(!"[]".equals(numsStr)){
            String[] numsStrArr = numsStr.replaceAll("\\[", "").replaceAll("\\]", "").split("\\,");
            nums = new int[numsStrArr.length];
            for (int i = 0; i < numsStrArr.length; i++) {
                nums[i] = Integer.parseInt(numsStrArr[i].trim());
            }
        }
        
        scanner.close();
        // 调用方法
        int[] res = frequencySort(nums);
        // 输出结果
        System.out.println(Arrays.toString(res));
    }
   
    
    public static int[] frequencySort(int[] nums) {
        Map<Integer, Integer> cnt = new HashMap<Integer, Integer>();
        for (int num : nums) {
            cnt.put(num, cnt.getOrDefault(num, 0) + 1);
        }
        List<Integer> list = new ArrayList<Integer>();
        for (int num : nums) {
            list.add(num);
        }
        Collections.sort(list, (a, b) -> {
            int cnt1 = cnt.get(a), cnt2 = cnt.get(b);
            return cnt1 != cnt2 ? cnt2 - cnt1 : b - a;
        });
        int length = nums.length;
        for (int i = 0; i < length; i++) {
            nums[i] = list.get(i);
        }
        return nums;
    }
        
    
}        
