import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int H = sc.nextInt();
        int M = sc.nextInt();
        sc.close();

        // 角度を求める
        double kakudoA = (double) (0.5 * (H * 60 + M));
        double kakudoB = (double) (6 * M);
        double kakudoC = Math.abs(kakudoA - kakudoB);

        double c = 0;
        if (kakudoC == 0) {
            c = Math.abs(A - B);
        } else if (kakudoC == 180) {
            c = A + B;
        } else if (kakudoC < 180) {
            c = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(Math.toRadians(kakudoC)));
        } else {
            kakudoC = 360 - kakudoC;
            c = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(Math.toRadians(kakudoC)));
        }
        System.out.println(c);
        return;
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int H = sc.nextInt();
        int M = sc.nextInt();
        sc.close();

        // 角度を求める
        double kakudoA = (double) (0.5 * (H * 60 + M));
        double kakudoB = (double) (6 * M);
        double kakudoC = Math.abs(kakudoA - kakudoB);

        double c = 0;
        if (kakudoC == 0) {
            c = Math.abs(A - B);
        } else if (kakudoC == 180) {
            c = A + B;
        } else if (kakudoC < 180) {
            c = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(Math.toRadians(kakudoC)));
        } else {
            kakudoC = 360 - kakudoC;
            c = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(Math.toRadians(kakudoC)));
        }
        System.out.println(c);
        return;
    }
} Main public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int H = sc.nextInt();
        int M = sc.nextInt();
        sc.close();

        // 角度を求める
        double kakudoA = (double) (0.5 * (H * 60 + M));
        double kakudoB = (double) (6 * M);
        double kakudoC = Math.abs(kakudoA - kakudoB);

        double c = 0;
        if (kakudoC == 0) {
            c = Math.abs(A - B);
        } else if (kakudoC == 180) {
            c = A + B;
        } else if (kakudoC < 180) {
            c = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(Math.toRadians(kakudoC)));
        } else {
            kakudoC = 360 - kakudoC;
            c = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(Math.toRadians(kakudoC)));
        }
        System.out.println(c);
        return;
    } main {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int H = sc.nextInt();
        int M = sc.nextInt();
        sc.close();

        // 角度を求める
        double kakudoA = (double) (0.5 * (H * 60 + M));
        double kakudoB = (double) (6 * M);
        double kakudoC = Math.abs(kakudoA - kakudoB);

        double c = 0;
        if (kakudoC == 0) {
            c = Math.abs(A - B);
        } else if (kakudoC == 180) {
            c = A + B;
        } else if (kakudoC < 180) {
            c = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(Math.toRadians(kakudoC)));
        } else {
            kakudoC = 360 - kakudoC;
            c = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(Math.toRadians(kakudoC)));
        }
        System.out.println(c);
        return;
    } 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 H = sc.nextInt(); H sc.nextInt() sc.nextInt sc int M = sc.nextInt(); M sc.nextInt() sc.nextInt sc sc.close() sc.close sc double kakudoA = (double) (0.5 * (H * 60 + M)); kakudoA (double) (0.5 * (H * 60 + M)) 0.5 (H * 60 + M) H * 60 H 60 M double kakudoB = (double) (6 * M); kakudoB (double) (6 * M) 6 M double kakudoC = Math.abs(kakudoA - kakudoB); kakudoC Math.abs(kakudoA - kakudoB) Math.abs Math kakudoA - kakudoB kakudoA kakudoB double c = 0; c 0 if (kakudoC == 0) {
            c = Math.abs(A - B);
        } else if (kakudoC == 180) {
            c = A + B;
        } else if (kakudoC < 180) {
            c = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(Math.toRadians(kakudoC)));
        } else {
            kakudoC = 360 - kakudoC;
            c = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(Math.toRadians(kakudoC)));
        } kakudoC == 0 kakudoC 0 {
            c = Math.abs(A - B);
        } c = Math.abs(A - B) c Math.abs(A - B) Math.abs Math A - B A B if (kakudoC == 180) {
            c = A + B;
        } else if (kakudoC < 180) {
            c = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(Math.toRadians(kakudoC)));
        } else {
            kakudoC = 360 - kakudoC;
            c = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(Math.toRadians(kakudoC)));
        } kakudoC == 180 kakudoC 180 {
            c = A + B;
        } c = A + B c A + B A B if (kakudoC < 180) {
            c = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(Math.toRadians(kakudoC)));
        } else {
            kakudoC = 360 - kakudoC;
            c = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(Math.toRadians(kakudoC)));
        } kakudoC < 180 kakudoC 180 {
            c = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(Math.toRadians(kakudoC)));
        } c = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(Math.toRadians(kakudoC))) c Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(Math.toRadians(kakudoC))) Math.sqrt Math A * A + B * B - 2 * A * B * Math.cos(Math.toRadians(kakudoC)) A * A + B * B A * A A A B * B B B 2 * A * B * Math.cos(Math.toRadians(kakudoC)) B 2 * A * B * Math.cos(Math.toRadians(kakudoC)) 2 A B Math.cos(Math.toRadians(kakudoC)) Math.cos Math Math.toRadians(kakudoC) Math.toRadians Math kakudoC {
            kakudoC = 360 - kakudoC;
            c = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(Math.toRadians(kakudoC)));
        } kakudoC = 360 - kakudoC kakudoC 360 - kakudoC 360 kakudoC c = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(Math.toRadians(kakudoC))) c Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(Math.toRadians(kakudoC))) Math.sqrt Math A * A + B * B - 2 * A * B * Math.cos(Math.toRadians(kakudoC)) A * A + B * B A * A A A B * B B B 2 * A * B * Math.cos(Math.toRadians(kakudoC)) B 2 * A * B * Math.cos(Math.toRadians(kakudoC)) 2 A B Math.cos(Math.toRadians(kakudoC)) Math.cos Math Math.toRadians(kakudoC) Math.toRadians Math kakudoC System.out.println(c) System.out.println System.out System System.out c return; String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int H = sc.nextInt();
        int M = sc.nextInt();
        sc.close();

        // 角度を求める
        double kakudoA = (double) (0.5 * (H * 60 + M));
        double kakudoB = (double) (6 * M);
        double kakudoC = Math.abs(kakudoA - kakudoB);

        double c = 0;
        if (kakudoC == 0) {
            c = Math.abs(A - B);
        } else if (kakudoC == 180) {
            c = A + B;
        } else if (kakudoC < 180) {
            c = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(Math.toRadians(kakudoC)));
        } else {
            kakudoC = 360 - kakudoC;
            c = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(Math.toRadians(kakudoC)));
        }
        System.out.println(c);
        return;
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int H = sc.nextInt();
        int M = sc.nextInt();
        sc.close();

        // 角度を求める
        double kakudoA = (double) (0.5 * (H * 60 + M));
        double kakudoB = (double) (6 * M);
        double kakudoC = Math.abs(kakudoA - kakudoB);

        double c = 0;
        if (kakudoC == 0) {
            c = Math.abs(A - B);
        } else if (kakudoC == 180) {
            c = A + B;
        } else if (kakudoC < 180) {
            c = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(Math.toRadians(kakudoC)));
        } else {
            kakudoC = 360 - kakudoC;
            c = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(Math.toRadians(kakudoC)));
        }
        System.out.println(c);
        return;
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int H = sc.nextInt();
        int M = sc.nextInt();
        sc.close();

        // 角度を求める
        double kakudoA = (double) (0.5 * (H * 60 + M));
        double kakudoB = (double) (6 * M);
        double kakudoC = Math.abs(kakudoA - kakudoB);

        double c = 0;
        if (kakudoC == 0) {
            c = Math.abs(A - B);
        } else if (kakudoC == 180) {
            c = A + B;
        } else if (kakudoC < 180) {
            c = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(Math.toRadians(kakudoC)));
        } else {
            kakudoC = 360 - kakudoC;
            c = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(Math.toRadians(kakudoC)));
        }
        System.out.println(c);
        return;
    }
}