import java.util.*; public class Main { static int[] counts = new int[]{20104, 20063, 19892, 20011, 19874, 20199, 19898, 20163, 19956, 19841}; public static void main(String[] args) { Scanner sc = new Scanner(System.in); for (char c : sc.next().toCharArray()) { if (c == '.') { continue; } counts[c - '0']--; } int left = 0; int right = 0; for (int i = 0; i < counts.length; i++) { if (counts[i] == -1) { left = i; } else if (counts[i] == 1) { right = i; } } System.out.println(left + " " + right); } }