import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        int H = Integer.parseInt(sc.next());
        int M = Integer.parseInt(sc.next());
        double Hdeg = H * 30 + M * 0.5;
        double Mdeg = M * 6;

        double deg = Hdeg - Mdeg;
        if (deg > 180) {
            deg = 360 - deg;
        }
        deg = Math.abs(deg);

        double cSquare = A * A + B * B - (2 * A * B * Math.cos(deg * Math.PI / 180));
        System.out.println(Math.sqrt(cSquare));
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        int H = Integer.parseInt(sc.next());
        int M = Integer.parseInt(sc.next());
        double Hdeg = H * 30 + M * 0.5;
        double Mdeg = M * 6;

        double deg = Hdeg - Mdeg;
        if (deg > 180) {
            deg = 360 - deg;
        }
        deg = Math.abs(deg);

        double cSquare = A * A + B * B - (2 * A * B * Math.cos(deg * Math.PI / 180));
        System.out.println(Math.sqrt(cSquare));
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        int H = Integer.parseInt(sc.next());
        int M = Integer.parseInt(sc.next());
        double Hdeg = H * 30 + M * 0.5;
        double Mdeg = M * 6;

        double deg = Hdeg - Mdeg;
        if (deg > 180) {
            deg = 360 - deg;
        }
        deg = Math.abs(deg);

        double cSquare = A * A + B * B - (2 * A * B * Math.cos(deg * Math.PI / 180));
        System.out.println(Math.sqrt(cSquare));
    } main {
        Scanner sc = new Scanner(System.in);
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        int H = Integer.parseInt(sc.next());
        int M = Integer.parseInt(sc.next());
        double Hdeg = H * 30 + M * 0.5;
        double Mdeg = M * 6;

        double deg = Hdeg - Mdeg;
        if (deg > 180) {
            deg = 360 - deg;
        }
        deg = Math.abs(deg);

        double cSquare = A * A + B * B - (2 * A * B * Math.cos(deg * Math.PI / 180));
        System.out.println(Math.sqrt(cSquare));
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int A = Integer.parseInt(sc.next()); A Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int B = Integer.parseInt(sc.next()); B Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int H = Integer.parseInt(sc.next()); H Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int M = Integer.parseInt(sc.next()); M Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc double Hdeg = H * 30 + M * 0.5; Hdeg H * 30 + M * 0.5 H * 30 H 30 M * 0.5 M 0.5 double Mdeg = M * 6; Mdeg M * 6 M 6 double deg = Hdeg - Mdeg; deg Hdeg - Mdeg Hdeg Mdeg if (deg > 180) {
            deg = 360 - deg;
        } deg > 180 deg 180 {
            deg = 360 - deg;
        } deg = 360 - deg deg 360 - deg 360 deg deg = Math.abs(deg) deg Math.abs(deg) Math.abs Math deg double cSquare = A * A + B * B - (2 * A * B * Math.cos(deg * Math.PI / 180)); cSquare A * A + B * B - (2 * A * B * Math.cos(deg * Math.PI / 180)) A * A + B * B A * A A A B * B B B (2 * A * B * Math.cos(deg * Math.PI / 180)) B 2 * A * B * Math.cos(deg * Math.PI / 180) 2 A B Math.cos(deg * Math.PI / 180) Math.cos Math deg * Math.PI / 180 deg * Math.PI deg Math.PI Math Math.PI 180 System.out.println(Math.sqrt(cSquare)) System.out.println System.out System System.out Math.sqrt(cSquare) Math.sqrt Math cSquare String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        int H = Integer.parseInt(sc.next());
        int M = Integer.parseInt(sc.next());
        double Hdeg = H * 30 + M * 0.5;
        double Mdeg = M * 6;

        double deg = Hdeg - Mdeg;
        if (deg > 180) {
            deg = 360 - deg;
        }
        deg = Math.abs(deg);

        double cSquare = A * A + B * B - (2 * A * B * Math.cos(deg * Math.PI / 180));
        System.out.println(Math.sqrt(cSquare));
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        int H = Integer.parseInt(sc.next());
        int M = Integer.parseInt(sc.next());
        double Hdeg = H * 30 + M * 0.5;
        double Mdeg = M * 6;

        double deg = Hdeg - Mdeg;
        if (deg > 180) {
            deg = 360 - deg;
        }
        deg = Math.abs(deg);

        double cSquare = A * A + B * B - (2 * A * B * Math.cos(deg * Math.PI / 180));
        System.out.println(Math.sqrt(cSquare));
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        int H = Integer.parseInt(sc.next());
        int M = Integer.parseInt(sc.next());
        double Hdeg = H * 30 + M * 0.5;
        double Mdeg = M * 6;

        double deg = Hdeg - Mdeg;
        if (deg > 180) {
            deg = 360 - deg;
        }
        deg = Math.abs(deg);

        double cSquare = A * A + B * B - (2 * A * B * Math.cos(deg * Math.PI / 180));
        System.out.println(Math.sqrt(cSquare));
    }
}
