
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			int A = scan.nextInt();
			int B = scan.nextInt();
			
			int[]s = new int[2000];
			
			int ase = (double)((A*25)/2)==(A*25.0)/2.0?(A*25)/2:(A*25)/2+1;
			int ako = (double)(((A+1)*25)/2)==((A+1)*25.0)/2.0?((A+1)*25)/2-1:((A+1)*25)/2;
			
			int bse = B*10;
			int bko = B*10+9;
			
			for(int i = ase-1;i<ako;i++) {
				s[i]++;
			}
			for(int i = bse-1;i<bko;i++) {
				s[i]++;
			}
			
			int ok=0;
			for(int i = 0;i<2000;i++) {
				if(s[i]==2) {
					ok=1;
					System.out.println(i+1);
					break;
				}
			}
			
			if(ok==0)System.out.println(-1);
			
			
			
			
		}	
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			int A = scan.nextInt();
			int B = scan.nextInt();
			
			int[]s = new int[2000];
			
			int ase = (double)((A*25)/2)==(A*25.0)/2.0?(A*25)/2:(A*25)/2+1;
			int ako = (double)(((A+1)*25)/2)==((A+1)*25.0)/2.0?((A+1)*25)/2-1:((A+1)*25)/2;
			
			int bse = B*10;
			int bko = B*10+9;
			
			for(int i = ase-1;i<ako;i++) {
				s[i]++;
			}
			for(int i = bse-1;i<bko;i++) {
				s[i]++;
			}
			
			int ok=0;
			for(int i = 0;i<2000;i++) {
				if(s[i]==2) {
					ok=1;
					System.out.println(i+1);
					break;
				}
			}
			
			if(ok==0)System.out.println(-1);
			
			
			
			
		}	
	}
} Main public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			int A = scan.nextInt();
			int B = scan.nextInt();
			
			int[]s = new int[2000];
			
			int ase = (double)((A*25)/2)==(A*25.0)/2.0?(A*25)/2:(A*25)/2+1;
			int ako = (double)(((A+1)*25)/2)==((A+1)*25.0)/2.0?((A+1)*25)/2-1:((A+1)*25)/2;
			
			int bse = B*10;
			int bko = B*10+9;
			
			for(int i = ase-1;i<ako;i++) {
				s[i]++;
			}
			for(int i = bse-1;i<bko;i++) {
				s[i]++;
			}
			
			int ok=0;
			for(int i = 0;i<2000;i++) {
				if(s[i]==2) {
					ok=1;
					System.out.println(i+1);
					break;
				}
			}
			
			if(ok==0)System.out.println(-1);
			
			
			
			
		}	
	} main {
		try(Scanner scan = new Scanner(System.in)){
			
			int A = scan.nextInt();
			int B = scan.nextInt();
			
			int[]s = new int[2000];
			
			int ase = (double)((A*25)/2)==(A*25.0)/2.0?(A*25)/2:(A*25)/2+1;
			int ako = (double)(((A+1)*25)/2)==((A+1)*25.0)/2.0?((A+1)*25)/2-1:((A+1)*25)/2;
			
			int bse = B*10;
			int bko = B*10+9;
			
			for(int i = ase-1;i<ako;i++) {
				s[i]++;
			}
			for(int i = bse-1;i<bko;i++) {
				s[i]++;
			}
			
			int ok=0;
			for(int i = 0;i<2000;i++) {
				if(s[i]==2) {
					ok=1;
					System.out.println(i+1);
					break;
				}
			}
			
			if(ok==0)System.out.println(-1);
			
			
			
			
		}	
	} try(Scanner scan = new Scanner(System.in)){
			
			int A = scan.nextInt();
			int B = scan.nextInt();
			
			int[]s = new int[2000];
			
			int ase = (double)((A*25)/2)==(A*25.0)/2.0?(A*25)/2:(A*25)/2+1;
			int ako = (double)(((A+1)*25)/2)==((A+1)*25.0)/2.0?((A+1)*25)/2-1:((A+1)*25)/2;
			
			int bse = B*10;
			int bko = B*10+9;
			
			for(int i = ase-1;i<ako;i++) {
				s[i]++;
			}
			for(int i = bse-1;i<bko;i++) {
				s[i]++;
			}
			
			int ok=0;
			for(int i = 0;i<2000;i++) {
				if(s[i]==2) {
					ok=1;
					System.out.println(i+1);
					break;
				}
			}
			
			if(ok==0)System.out.println(-1);
			
			
			
			
		} {
			
			int A = scan.nextInt();
			int B = scan.nextInt();
			
			int[]s = new int[2000];
			
			int ase = (double)((A*25)/2)==(A*25.0)/2.0?(A*25)/2:(A*25)/2+1;
			int ako = (double)(((A+1)*25)/2)==((A+1)*25.0)/2.0?((A+1)*25)/2-1:((A+1)*25)/2;
			
			int bse = B*10;
			int bko = B*10+9;
			
			for(int i = ase-1;i<ako;i++) {
				s[i]++;
			}
			for(int i = bse-1;i<bko;i++) {
				s[i]++;
			}
			
			int ok=0;
			for(int i = 0;i<2000;i++) {
				if(s[i]==2) {
					ok=1;
					System.out.println(i+1);
					break;
				}
			}
			
			if(ok==0)System.out.println(-1);
			
			
			
			
		} Scanner scan = new Scanner(System.in) Scanner scan = new Scanner(System.in) new Scanner(System.in) int A = scan.nextInt(); A scan.nextInt() scan.nextInt scan int B = scan.nextInt(); B scan.nextInt() scan.nextInt scan int[]s = new int[2000]; s new int[2000] 2000 int ase = (double)((A*25)/2)==(A*25.0)/2.0?(A*25)/2:(A*25)/2+1; ase (double)((A*25)/2)==(A*25.0)/2.0?(A*25)/2:(A*25)/2+1 (double)((A*25)/2)==(A*25.0)/2.0 (double)((A*25)/2) (A*25) A 25 2 (A*25.0)/2.0 (A*25.0) A 25.0 2.0 (A*25)/2 (A*25) A 25 2 (A*25)/2+1 (A*25)/2 (A*25) A 25 2 1 int ako = (double)(((A+1)*25)/2)==((A+1)*25.0)/2.0?((A+1)*25)/2-1:((A+1)*25)/2; ako (double)(((A+1)*25)/2)==((A+1)*25.0)/2.0?((A+1)*25)/2-1:((A+1)*25)/2 (double)(((A+1)*25)/2)==((A+1)*25.0)/2.0 (double)(((A+1)*25)/2) ((A+1)*25) (A+1) A 1 25 2 ((A+1)*25.0)/2.0 ((A+1)*25.0) (A+1) A 1 25.0 2.0 ((A+1)*25)/2-1 ((A+1)*25)/2 ((A+1)*25) (A+1) A 1 25 2 1 ((A+1)*25)/2 ((A+1)*25) (A+1) A 1 25 2 int bse = B*10; bse B*10 B 10 int bko = B*10+9; bko B*10+9 B*10 B 10 9 for(int i = ase-1;i<ako;i++) {
				s[i]++;
			} int i = ase-1; int i = ase-1; i ase-1 ase 1 i<ako i ako i++ i++ i {
				s[i]++;
			} {
				s[i]++;
			} s[i]++ s[i] s i for(int i = bse-1;i<bko;i++) {
				s[i]++;
			} int i = bse-1; int i = bse-1; i bse-1 bse 1 i<bko i bko i++ i++ i {
				s[i]++;
			} {
				s[i]++;
			} s[i]++ s[i] s i int ok=0; ok 0 for(int i = 0;i<2000;i++) {
				if(s[i]==2) {
					ok=1;
					System.out.println(i+1);
					break;
				}
			} int i = 0; int i = 0; i 0 i<2000 i 2000 i++ i++ i {
				if(s[i]==2) {
					ok=1;
					System.out.println(i+1);
					break;
				}
			} {
				if(s[i]==2) {
					ok=1;
					System.out.println(i+1);
					break;
				}
			} if(s[i]==2) {
					ok=1;
					System.out.println(i+1);
					break;
				} s[i]==2 s[i] s i 2 {
					ok=1;
					System.out.println(i+1);
					break;
				} ok=1 ok 1 System.out.println(i+1) System.out.println System.out System System.out i+1 i 1 break; if(ok==0)System.out.println(-1); ok==0 ok 0 System.out.println(-1) System.out.println System.out System System.out -1 1 String[]args args public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			int A = scan.nextInt();
			int B = scan.nextInt();
			
			int[]s = new int[2000];
			
			int ase = (double)((A*25)/2)==(A*25.0)/2.0?(A*25)/2:(A*25)/2+1;
			int ako = (double)(((A+1)*25)/2)==((A+1)*25.0)/2.0?((A+1)*25)/2-1:((A+1)*25)/2;
			
			int bse = B*10;
			int bko = B*10+9;
			
			for(int i = ase-1;i<ako;i++) {
				s[i]++;
			}
			for(int i = bse-1;i<bko;i++) {
				s[i]++;
			}
			
			int ok=0;
			for(int i = 0;i<2000;i++) {
				if(s[i]==2) {
					ok=1;
					System.out.println(i+1);
					break;
				}
			}
			
			if(ok==0)System.out.println(-1);
			
			
			
			
		}	
	}
} public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			int A = scan.nextInt();
			int B = scan.nextInt();
			
			int[]s = new int[2000];
			
			int ase = (double)((A*25)/2)==(A*25.0)/2.0?(A*25)/2:(A*25)/2+1;
			int ako = (double)(((A+1)*25)/2)==((A+1)*25.0)/2.0?((A+1)*25)/2-1:((A+1)*25)/2;
			
			int bse = B*10;
			int bko = B*10+9;
			
			for(int i = ase-1;i<ako;i++) {
				s[i]++;
			}
			for(int i = bse-1;i<bko;i++) {
				s[i]++;
			}
			
			int ok=0;
			for(int i = 0;i<2000;i++) {
				if(s[i]==2) {
					ok=1;
					System.out.println(i+1);
					break;
				}
			}
			
			if(ok==0)System.out.println(-1);
			
			
			
			
		}	
	}
} Main

import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			int A = scan.nextInt();
			int B = scan.nextInt();
			
			int[]s = new int[2000];
			
			int ase = (double)((A*25)/2)==(A*25.0)/2.0?(A*25)/2:(A*25)/2+1;
			int ako = (double)(((A+1)*25)/2)==((A+1)*25.0)/2.0?((A+1)*25)/2-1:((A+1)*25)/2;
			
			int bse = B*10;
			int bko = B*10+9;
			
			for(int i = ase-1;i<ako;i++) {
				s[i]++;
			}
			for(int i = bse-1;i<bko;i++) {
				s[i]++;
			}
			
			int ok=0;
			for(int i = 0;i<2000;i++) {
				if(s[i]==2) {
					ok=1;
					System.out.println(i+1);
					break;
				}
			}
			
			if(ok==0)System.out.println(-1);
			
			
			
			
		}	
	}
}
