import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
 
public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int a = 100 * A / 8;
        if (((100 * A)%8 != 0)) {
            a++;
        }
        int ap = 100 * (A+1) / 8;
        if ((100 * (A+1))%8 == 0) {
            ap--;
        }
        int b = 10 * B;
        int bp = 10 * (B+1);
        List<Integer> in = new ArrayList<>();
        List<Integer> out = new ArrayList<>();
        List<Integer> ans = new ArrayList<>();
        for (int i = a;i <= ap;i++) {
            in.add(i);
        }
        for (int i = b; i < bp;i++) {
            out.add(i);
        }
        for (Integer i :out) {
            if (in.contains(i)) {
                ans.add(i);
            }
        }
        if (ans.isEmpty()) {
            System.out.println(-1);
        } else {
            System.out.println(ans.get(0));
        }
    }
} import java.util.ArrayList; ArrayList java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int a = 100 * A / 8;
        if (((100 * A)%8 != 0)) {
            a++;
        }
        int ap = 100 * (A+1) / 8;
        if ((100 * (A+1))%8 == 0) {
            ap--;
        }
        int b = 10 * B;
        int bp = 10 * (B+1);
        List<Integer> in = new ArrayList<>();
        List<Integer> out = new ArrayList<>();
        List<Integer> ans = new ArrayList<>();
        for (int i = a;i <= ap;i++) {
            in.add(i);
        }
        for (int i = b; i < bp;i++) {
            out.add(i);
        }
        for (Integer i :out) {
            if (in.contains(i)) {
                ans.add(i);
            }
        }
        if (ans.isEmpty()) {
            System.out.println(-1);
        } else {
            System.out.println(ans.get(0));
        }
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int a = 100 * A / 8;
        if (((100 * A)%8 != 0)) {
            a++;
        }
        int ap = 100 * (A+1) / 8;
        if ((100 * (A+1))%8 == 0) {
            ap--;
        }
        int b = 10 * B;
        int bp = 10 * (B+1);
        List<Integer> in = new ArrayList<>();
        List<Integer> out = new ArrayList<>();
        List<Integer> ans = new ArrayList<>();
        for (int i = a;i <= ap;i++) {
            in.add(i);
        }
        for (int i = b; i < bp;i++) {
            out.add(i);
        }
        for (Integer i :out) {
            if (in.contains(i)) {
                ans.add(i);
            }
        }
        if (ans.isEmpty()) {
            System.out.println(-1);
        } else {
            System.out.println(ans.get(0));
        }
    } main {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int a = 100 * A / 8;
        if (((100 * A)%8 != 0)) {
            a++;
        }
        int ap = 100 * (A+1) / 8;
        if ((100 * (A+1))%8 == 0) {
            ap--;
        }
        int b = 10 * B;
        int bp = 10 * (B+1);
        List<Integer> in = new ArrayList<>();
        List<Integer> out = new ArrayList<>();
        List<Integer> ans = new ArrayList<>();
        for (int i = a;i <= ap;i++) {
            in.add(i);
        }
        for (int i = b; i < bp;i++) {
            out.add(i);
        }
        for (Integer i :out) {
            if (in.contains(i)) {
                ans.add(i);
            }
        }
        if (ans.isEmpty()) {
            System.out.println(-1);
        } else {
            System.out.println(ans.get(0));
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int A = sc.nextInt(); A sc.nextInt() sc.nextInt sc int B = sc.nextInt(); B sc.nextInt() sc.nextInt sc int a = 100 * A / 8; a 100 * A / 8 100 * A 100 A 8 if (((100 * A)%8 != 0)) {
            a++;
        } ((100 * A)%8 != 0) (100 * A)%8 (100 * A) 100 A 8 0 {
            a++;
        } a++ a int ap = 100 * (A+1) / 8; ap 100 * (A+1) / 8 100 * (A+1) 100 (A+1) A 1 8 if ((100 * (A+1))%8 == 0) {
            ap--;
        } (100 * (A+1))%8 == 0 (100 * (A+1))%8 (100 * (A+1)) 100 (A+1) A 1 8 0 {
            ap--;
        } ap-- ap int b = 10 * B; b 10 * B 10 B int bp = 10 * (B+1); bp 10 * (B+1) 10 (B+1) B 1 List<Integer> in = new ArrayList<>(); in new ArrayList<>() List<Integer> out = new ArrayList<>(); out new ArrayList<>() List<Integer> ans = new ArrayList<>(); ans new ArrayList<>() for (int i = a;i <= ap;i++) {
            in.add(i);
        } int i = a; int i = a; i a i <= ap i ap i++ i++ i {
            in.add(i);
        } {
            in.add(i);
        } in.add(i) in.add in i for (int i = b; i < bp;i++) {
            out.add(i);
        } int i = b; int i = b; i b i < bp i bp i++ i++ i {
            out.add(i);
        } {
            out.add(i);
        } out.add(i) out.add out i for (Integer i :out) {
            if (in.contains(i)) {
                ans.add(i);
            }
        } Integer i out {
            if (in.contains(i)) {
                ans.add(i);
            }
        } {
            if (in.contains(i)) {
                ans.add(i);
            }
        } if (in.contains(i)) {
                ans.add(i);
            } in.contains(i) in.contains in i {
                ans.add(i);
            } ans.add(i) ans.add ans i if (ans.isEmpty()) {
            System.out.println(-1);
        } else {
            System.out.println(ans.get(0));
        } ans.isEmpty() ans.isEmpty ans {
            System.out.println(-1);
        } System.out.println(-1) System.out.println System.out System System.out -1 1 {
            System.out.println(ans.get(0));
        } System.out.println(ans.get(0)) System.out.println System.out System System.out ans.get(0) ans.get ans 0 String[] args args public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int a = 100 * A / 8;
        if (((100 * A)%8 != 0)) {
            a++;
        }
        int ap = 100 * (A+1) / 8;
        if ((100 * (A+1))%8 == 0) {
            ap--;
        }
        int b = 10 * B;
        int bp = 10 * (B+1);
        List<Integer> in = new ArrayList<>();
        List<Integer> out = new ArrayList<>();
        List<Integer> ans = new ArrayList<>();
        for (int i = a;i <= ap;i++) {
            in.add(i);
        }
        for (int i = b; i < bp;i++) {
            out.add(i);
        }
        for (Integer i :out) {
            if (in.contains(i)) {
                ans.add(i);
            }
        }
        if (ans.isEmpty()) {
            System.out.println(-1);
        } else {
            System.out.println(ans.get(0));
        }
    }
} public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int a = 100 * A / 8;
        if (((100 * A)%8 != 0)) {
            a++;
        }
        int ap = 100 * (A+1) / 8;
        if ((100 * (A+1))%8 == 0) {
            ap--;
        }
        int b = 10 * B;
        int bp = 10 * (B+1);
        List<Integer> in = new ArrayList<>();
        List<Integer> out = new ArrayList<>();
        List<Integer> ans = new ArrayList<>();
        for (int i = a;i <= ap;i++) {
            in.add(i);
        }
        for (int i = b; i < bp;i++) {
            out.add(i);
        }
        for (Integer i :out) {
            if (in.contains(i)) {
                ans.add(i);
            }
        }
        if (ans.isEmpty()) {
            System.out.println(-1);
        } else {
            System.out.println(ans.get(0));
        }
    }
} Main
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
 
public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int a = 100 * A / 8;
        if (((100 * A)%8 != 0)) {
            a++;
        }
        int ap = 100 * (A+1) / 8;
        if ((100 * (A+1))%8 == 0) {
            ap--;
        }
        int b = 10 * B;
        int bp = 10 * (B+1);
        List<Integer> in = new ArrayList<>();
        List<Integer> out = new ArrayList<>();
        List<Integer> ans = new ArrayList<>();
        for (int i = a;i <= ap;i++) {
            in.add(i);
        }
        for (int i = b; i < bp;i++) {
            out.add(i);
        }
        for (Integer i :out) {
            if (in.contains(i)) {
                ans.add(i);
            }
        }
        if (ans.isEmpty()) {
            System.out.println(-1);
        } else {
            System.out.println(ans.get(0));
        }
    }
}