import java.awt.Point; import java.awt.Rectangle; import java.awt.geom.Rectangle2D; import java.io.BufferedInputStream; import java.io.IOException; import java.math.BigDecimal; import java.math.BigInteger; import java.util.*; import java.util.Map.Entry; import java.util.concurrent.ConcurrentSkipListSet; public class Main { static final long C = 1000000007; static final int CY = 1000000000; //long[] F; int[] nums = new int[]{ 20104 , 20063 , 19892 , 20011 , 19874 , 20199 , 19898 , 20163 , 19956 ,19841}; public void calc() { StringBuilder sb = new StringBuilder(); BufferedInputStream bs = new BufferedInputStream(System.in); Scanner sc = new Scanner(bs); int now[] = new int[10]; int ans1 = 0, ans2 =0; String s = sc.next(); for (int i=0; i < s.length() ; i++ ) { char c = s.charAt(i); try { now[c - '0']++; }catch (Exception e) { } } for (int i=0; i < 10; i++) { if (nums[i] < now[i]) { ans1 = i; }else if (nums[i] > now[i]) { ans2 = i; } } System.out.println(ans1 +" "+ ans2); } public static void main(String[] args) { Main main = new Main(); main.calc(); } }