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 noTaxAmin = a * 100 % 8 == 0 ? a * 100 / 8 : a * 100 / 8 + 1;
        int noTaxAmax = (a + 1) * 100 % 8 == 0 ? (a + 1) * 100 / 8 - 1 : (a + 1) * 100 / 8;
        int noTaxBmin = b * 100 % 10 == 0 ? b * 100 / 10 : b * 100 / 10 + 1;
        int noTaxBmax = (b + 1) * 100 % 10 == 0 ? (b + 1) * 100 / 10 - 1 : (b + 1) * 100 / 10;
        if (noTaxAmin <= noTaxBmax && noTaxBmin <= noTaxAmax) {
            System.out.println(Math.max(noTaxAmin, noTaxBmin));

        }else {
            System.out.println(-1);
        }
    }
} 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 noTaxAmin = a * 100 % 8 == 0 ? a * 100 / 8 : a * 100 / 8 + 1;
        int noTaxAmax = (a + 1) * 100 % 8 == 0 ? (a + 1) * 100 / 8 - 1 : (a + 1) * 100 / 8;
        int noTaxBmin = b * 100 % 10 == 0 ? b * 100 / 10 : b * 100 / 10 + 1;
        int noTaxBmax = (b + 1) * 100 % 10 == 0 ? (b + 1) * 100 / 10 - 1 : (b + 1) * 100 / 10;
        if (noTaxAmin <= noTaxBmax && noTaxBmin <= noTaxAmax) {
            System.out.println(Math.max(noTaxAmin, noTaxBmin));

        }else {
            System.out.println(-1);
        }
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        int noTaxAmin = a * 100 % 8 == 0 ? a * 100 / 8 : a * 100 / 8 + 1;
        int noTaxAmax = (a + 1) * 100 % 8 == 0 ? (a + 1) * 100 / 8 - 1 : (a + 1) * 100 / 8;
        int noTaxBmin = b * 100 % 10 == 0 ? b * 100 / 10 : b * 100 / 10 + 1;
        int noTaxBmax = (b + 1) * 100 % 10 == 0 ? (b + 1) * 100 / 10 - 1 : (b + 1) * 100 / 10;
        if (noTaxAmin <= noTaxBmax && noTaxBmin <= noTaxAmax) {
            System.out.println(Math.max(noTaxAmin, noTaxBmin));

        }else {
            System.out.println(-1);
        }
    } main {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        int noTaxAmin = a * 100 % 8 == 0 ? a * 100 / 8 : a * 100 / 8 + 1;
        int noTaxAmax = (a + 1) * 100 % 8 == 0 ? (a + 1) * 100 / 8 - 1 : (a + 1) * 100 / 8;
        int noTaxBmin = b * 100 % 10 == 0 ? b * 100 / 10 : b * 100 / 10 + 1;
        int noTaxBmax = (b + 1) * 100 % 10 == 0 ? (b + 1) * 100 / 10 - 1 : (b + 1) * 100 / 10;
        if (noTaxAmin <= noTaxBmax && noTaxBmin <= noTaxAmax) {
            System.out.println(Math.max(noTaxAmin, noTaxBmin));

        }else {
            System.out.println(-1);
        }
    } 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 noTaxAmin = a * 100 % 8 == 0 ? a * 100 / 8 : a * 100 / 8 + 1; noTaxAmin a * 100 % 8 == 0 ? a * 100 / 8 : a * 100 / 8 + 1 a * 100 % 8 == 0 a * 100 % 8 a * 100 a 100 8 0 a * 100 / 8 a * 100 a 100 8 a * 100 / 8 + 1 a * 100 / 8 a * 100 a 100 8 1 int noTaxAmax = (a + 1) * 100 % 8 == 0 ? (a + 1) * 100 / 8 - 1 : (a + 1) * 100 / 8; noTaxAmax (a + 1) * 100 % 8 == 0 ? (a + 1) * 100 / 8 - 1 : (a + 1) * 100 / 8 (a + 1) * 100 % 8 == 0 (a + 1) * 100 % 8 (a + 1) * 100 (a + 1) a 1 100 8 0 (a + 1) * 100 / 8 - 1 (a + 1) * 100 / 8 (a + 1) * 100 (a + 1) a 1 100 8 1 (a + 1) * 100 / 8 (a + 1) * 100 (a + 1) a 1 100 8 int noTaxBmin = b * 100 % 10 == 0 ? b * 100 / 10 : b * 100 / 10 + 1; noTaxBmin b * 100 % 10 == 0 ? b * 100 / 10 : b * 100 / 10 + 1 b * 100 % 10 == 0 b * 100 % 10 b * 100 b 100 10 0 b * 100 / 10 b * 100 b 100 10 b * 100 / 10 + 1 b * 100 / 10 b * 100 b 100 10 1 int noTaxBmax = (b + 1) * 100 % 10 == 0 ? (b + 1) * 100 / 10 - 1 : (b + 1) * 100 / 10; noTaxBmax (b + 1) * 100 % 10 == 0 ? (b + 1) * 100 / 10 - 1 : (b + 1) * 100 / 10 (b + 1) * 100 % 10 == 0 (b + 1) * 100 % 10 (b + 1) * 100 (b + 1) b 1 100 10 0 (b + 1) * 100 / 10 - 1 (b + 1) * 100 / 10 (b + 1) * 100 (b + 1) b 1 100 10 1 (b + 1) * 100 / 10 (b + 1) * 100 (b + 1) b 1 100 10 if (noTaxAmin <= noTaxBmax && noTaxBmin <= noTaxAmax) {
            System.out.println(Math.max(noTaxAmin, noTaxBmin));

        }else {
            System.out.println(-1);
        } noTaxAmin <= noTaxBmax && noTaxBmin <= noTaxAmax noTaxAmin <= noTaxBmax noTaxAmin noTaxBmax noTaxBmin <= noTaxAmax noTaxBmin noTaxAmax {
            System.out.println(Math.max(noTaxAmin, noTaxBmin));

        } System.out.println(Math.max(noTaxAmin, noTaxBmin)) System.out.println System.out System System.out Math.max(noTaxAmin, noTaxBmin) Math.max Math noTaxAmin noTaxBmin {
            System.out.println(-1);
        } 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) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        int noTaxAmin = a * 100 % 8 == 0 ? a * 100 / 8 : a * 100 / 8 + 1;
        int noTaxAmax = (a + 1) * 100 % 8 == 0 ? (a + 1) * 100 / 8 - 1 : (a + 1) * 100 / 8;
        int noTaxBmin = b * 100 % 10 == 0 ? b * 100 / 10 : b * 100 / 10 + 1;
        int noTaxBmax = (b + 1) * 100 % 10 == 0 ? (b + 1) * 100 / 10 - 1 : (b + 1) * 100 / 10;
        if (noTaxAmin <= noTaxBmax && noTaxBmin <= noTaxAmax) {
            System.out.println(Math.max(noTaxAmin, noTaxBmin));

        }else {
            System.out.println(-1);
        }
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        int noTaxAmin = a * 100 % 8 == 0 ? a * 100 / 8 : a * 100 / 8 + 1;
        int noTaxAmax = (a + 1) * 100 % 8 == 0 ? (a + 1) * 100 / 8 - 1 : (a + 1) * 100 / 8;
        int noTaxBmin = b * 100 % 10 == 0 ? b * 100 / 10 : b * 100 / 10 + 1;
        int noTaxBmax = (b + 1) * 100 % 10 == 0 ? (b + 1) * 100 / 10 - 1 : (b + 1) * 100 / 10;
        if (noTaxAmin <= noTaxBmax && noTaxBmin <= noTaxAmax) {
            System.out.println(Math.max(noTaxAmin, noTaxBmin));

        }else {
            System.out.println(-1);
        }
    }
} Main
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 noTaxAmin = a * 100 % 8 == 0 ? a * 100 / 8 : a * 100 / 8 + 1;
        int noTaxAmax = (a + 1) * 100 % 8 == 0 ? (a + 1) * 100 / 8 - 1 : (a + 1) * 100 / 8;
        int noTaxBmin = b * 100 % 10 == 0 ? b * 100 / 10 : b * 100 / 10 + 1;
        int noTaxBmax = (b + 1) * 100 % 10 == 0 ? (b + 1) * 100 / 10 - 1 : (b + 1) * 100 / 10;
        if (noTaxAmin <= noTaxBmax && noTaxBmin <= noTaxAmax) {
            System.out.println(Math.max(noTaxAmin, noTaxBmin));

        }else {
            System.out.println(-1);
        }
    }
}
