PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#SP0000016. Tần suất nguyên tố (Prime Frequency)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Tần suất nguyên tố (Prime Frequency)

Prime Frequency

Source: UVa

Version: Phuoc Hung OJ Extended

Problem Statement

Given a string ss containing only the decimal digits 0–9, uppercase letters A–Z, and lowercase letters a–z, a character's frequency is its number of occurrences. Collect every character whose frequency is prime (greater than 11 with exactly two positive divisors) and sort the resulting characters by increasing ASCII code. Digits precede uppercase letters, which precede lowercase letters. Use empty if no character qualifies.

Input

One nonempty line contains string ss, consisting of the specified letters and digits.

Output

Print exactly Case 1: followed by the sorted qualifying characters, or empty if there are none. The number 1 is the label of the sole data set in this adaptation.

Subtasks

  • Subtask 1 (20 points): 1≤∣s∣≤201\le |s|\le 20; all characters belong to 0–9, A–Z or a–z.
  • Subtask 2 (30 points): 1≤∣s∣≤2001\le |s|\le 200; all characters belong to 0–9, A–Z or a–z.
  • Subtask 3 (50 points): 1≤∣s∣≤20001\le |s|\le 2000; all characters belong to 0–9, A–Z or a–z.

Examples

Input

ABCC

Output

Case 1: C

Explanation

A and B occur once each, while C occurs twice. Only frequency 22 is prime, so the result is Case 1: C.

Input

AABBBBDDDDD

Output

Case 1: AD

Explanation

A appears twice, B four times, and D five times. Frequencies 22 and 55 are prime, whereas 44 is composite, so the sorted answer is AD.

Input

ABCDFFFF

Output

Case 1: empty

Explanation

Each of A, B, C, D occurs once and F occurs four times. Since neither 11 nor 44 is prime, no character qualifies; print empty.