import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double A = sc.nextDouble();
        double B = sc.nextDouble();
        double H = sc.nextDouble();
        double M = sc.nextDouble();
        sc.close();

        // 一分ごとの分針の角度の増減値を求める
        double perMinRad = 360.0000 / 60.0000;

        // 一時間ごとの時針の角度の増減値を求める
        double perHourRad = 360.0000 / (12.0000 * 60.0000);

        // 分針の角度
        double minRad = perMinRad * M;

        // 時針の角度
        double hourRad = (H * 60 * perHourRad) + (M * perHourRad);

        double rad = hourRad - minRad;

        if (rad > 180) {
            rad = 360.0000 - rad;
        }

        if (rad == 180.0) {
            System.out.println(A + B);
        } else {
            rad = Math.toRadians(rad);
            double cosRad = Math.cos(rad);
            double res = Math.sqrt(Math.pow(A, 2) + Math.pow(B, 2) - (2 * A * B * cosRad));
            System.out.println(res);
        }
    }
} import java.util.*; util.* java public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double A = sc.nextDouble();
        double B = sc.nextDouble();
        double H = sc.nextDouble();
        double M = sc.nextDouble();
        sc.close();

        // 一分ごとの分針の角度の増減値を求める
        double perMinRad = 360.0000 / 60.0000;

        // 一時間ごとの時針の角度の増減値を求める
        double perHourRad = 360.0000 / (12.0000 * 60.0000);

        // 分針の角度
        double minRad = perMinRad * M;

        // 時針の角度
        double hourRad = (H * 60 * perHourRad) + (M * perHourRad);

        double rad = hourRad - minRad;

        if (rad > 180) {
            rad = 360.0000 - rad;
        }

        if (rad == 180.0) {
            System.out.println(A + B);
        } else {
            rad = Math.toRadians(rad);
            double cosRad = Math.cos(rad);
            double res = Math.sqrt(Math.pow(A, 2) + Math.pow(B, 2) - (2 * A * B * cosRad));
            System.out.println(res);
        }
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double A = sc.nextDouble();
        double B = sc.nextDouble();
        double H = sc.nextDouble();
        double M = sc.nextDouble();
        sc.close();

        // 一分ごとの分針の角度の増減値を求める
        double perMinRad = 360.0000 / 60.0000;

        // 一時間ごとの時針の角度の増減値を求める
        double perHourRad = 360.0000 / (12.0000 * 60.0000);

        // 分針の角度
        double minRad = perMinRad * M;

        // 時針の角度
        double hourRad = (H * 60 * perHourRad) + (M * perHourRad);

        double rad = hourRad - minRad;

        if (rad > 180) {
            rad = 360.0000 - rad;
        }

        if (rad == 180.0) {
            System.out.println(A + B);
        } else {
            rad = Math.toRadians(rad);
            double cosRad = Math.cos(rad);
            double res = Math.sqrt(Math.pow(A, 2) + Math.pow(B, 2) - (2 * A * B * cosRad));
            System.out.println(res);
        }
    } main {
        Scanner sc = new Scanner(System.in);
        double A = sc.nextDouble();
        double B = sc.nextDouble();
        double H = sc.nextDouble();
        double M = sc.nextDouble();
        sc.close();

        // 一分ごとの分針の角度の増減値を求める
        double perMinRad = 360.0000 / 60.0000;

        // 一時間ごとの時針の角度の増減値を求める
        double perHourRad = 360.0000 / (12.0000 * 60.0000);

        // 分針の角度
        double minRad = perMinRad * M;

        // 時針の角度
        double hourRad = (H * 60 * perHourRad) + (M * perHourRad);

        double rad = hourRad - minRad;

        if (rad > 180) {
            rad = 360.0000 - rad;
        }

        if (rad == 180.0) {
            System.out.println(A + B);
        } else {
            rad = Math.toRadians(rad);
            double cosRad = Math.cos(rad);
            double res = Math.sqrt(Math.pow(A, 2) + Math.pow(B, 2) - (2 * A * B * cosRad));
            System.out.println(res);
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) double A = sc.nextDouble(); A sc.nextDouble() sc.nextDouble sc double B = sc.nextDouble(); B sc.nextDouble() sc.nextDouble sc double H = sc.nextDouble(); H sc.nextDouble() sc.nextDouble sc double M = sc.nextDouble(); M sc.nextDouble() sc.nextDouble sc sc.close() sc.close sc double perMinRad = 360.0000 / 60.0000; perMinRad 360.0000 / 60.0000 360.0000 60.0000 double perHourRad = 360.0000 / (12.0000 * 60.0000); perHourRad 360.0000 / (12.0000 * 60.0000) 360.0000 (12.0000 * 60.0000) 12.0000 60.0000 double minRad = perMinRad * M; minRad perMinRad * M perMinRad M double hourRad = (H * 60 * perHourRad) + (M * perHourRad); hourRad (H * 60 * perHourRad) + (M * perHourRad) (H * 60 * perHourRad) H * 60 * perHourRad H 60 perHourRad (M * perHourRad) M perHourRad double rad = hourRad - minRad; rad hourRad - minRad hourRad minRad if (rad > 180) {
            rad = 360.0000 - rad;
        } rad > 180 rad 180 {
            rad = 360.0000 - rad;
        } rad = 360.0000 - rad rad 360.0000 - rad 360.0000 rad if (rad == 180.0) {
            System.out.println(A + B);
        } else {
            rad = Math.toRadians(rad);
            double cosRad = Math.cos(rad);
            double res = Math.sqrt(Math.pow(A, 2) + Math.pow(B, 2) - (2 * A * B * cosRad));
            System.out.println(res);
        } rad == 180.0 rad 180.0 {
            System.out.println(A + B);
        } System.out.println(A + B) System.out.println System.out System System.out A + B A B {
            rad = Math.toRadians(rad);
            double cosRad = Math.cos(rad);
            double res = Math.sqrt(Math.pow(A, 2) + Math.pow(B, 2) - (2 * A * B * cosRad));
            System.out.println(res);
        } rad = Math.toRadians(rad) rad Math.toRadians(rad) Math.toRadians Math rad double cosRad = Math.cos(rad); cosRad Math.cos(rad) Math.cos Math rad double res = Math.sqrt(Math.pow(A, 2) + Math.pow(B, 2) - (2 * A * B * cosRad)); res Math.sqrt(Math.pow(A, 2) + Math.pow(B, 2) - (2 * A * B * cosRad)) Math.sqrt Math Math.pow(A, 2) + Math.pow(B, 2) - (2 * A * B * cosRad) Math.pow(A, 2) + Math.pow(B, 2) Math.pow(A, 2) Math.pow Math A 2 Math.pow(B, 2) Math.pow Math B 2 (2 * A * B * cosRad) B 2 * A * B * cosRad 2 A B cosRad System.out.println(res) System.out.println System.out System System.out res String[] args args public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double A = sc.nextDouble();
        double B = sc.nextDouble();
        double H = sc.nextDouble();
        double M = sc.nextDouble();
        sc.close();

        // 一分ごとの分針の角度の増減値を求める
        double perMinRad = 360.0000 / 60.0000;

        // 一時間ごとの時針の角度の増減値を求める
        double perHourRad = 360.0000 / (12.0000 * 60.0000);

        // 分針の角度
        double minRad = perMinRad * M;

        // 時針の角度
        double hourRad = (H * 60 * perHourRad) + (M * perHourRad);

        double rad = hourRad - minRad;

        if (rad > 180) {
            rad = 360.0000 - rad;
        }

        if (rad == 180.0) {
            System.out.println(A + B);
        } else {
            rad = Math.toRadians(rad);
            double cosRad = Math.cos(rad);
            double res = Math.sqrt(Math.pow(A, 2) + Math.pow(B, 2) - (2 * A * B * cosRad));
            System.out.println(res);
        }
    }
} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double A = sc.nextDouble();
        double B = sc.nextDouble();
        double H = sc.nextDouble();
        double M = sc.nextDouble();
        sc.close();

        // 一分ごとの分針の角度の増減値を求める
        double perMinRad = 360.0000 / 60.0000;

        // 一時間ごとの時針の角度の増減値を求める
        double perHourRad = 360.0000 / (12.0000 * 60.0000);

        // 分針の角度
        double minRad = perMinRad * M;

        // 時針の角度
        double hourRad = (H * 60 * perHourRad) + (M * perHourRad);

        double rad = hourRad - minRad;

        if (rad > 180) {
            rad = 360.0000 - rad;
        }

        if (rad == 180.0) {
            System.out.println(A + B);
        } else {
            rad = Math.toRadians(rad);
            double cosRad = Math.cos(rad);
            double res = Math.sqrt(Math.pow(A, 2) + Math.pow(B, 2) - (2 * A * B * cosRad));
            System.out.println(res);
        }
    }
} Main
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double A = sc.nextDouble();
        double B = sc.nextDouble();
        double H = sc.nextDouble();
        double M = sc.nextDouble();
        sc.close();

        // 一分ごとの分針の角度の増減値を求める
        double perMinRad = 360.0000 / 60.0000;

        // 一時間ごとの時針の角度の増減値を求める
        double perHourRad = 360.0000 / (12.0000 * 60.0000);

        // 分針の角度
        double minRad = perMinRad * M;

        // 時針の角度
        double hourRad = (H * 60 * perHourRad) + (M * perHourRad);

        double rad = hourRad - minRad;

        if (rad > 180) {
            rad = 360.0000 - rad;
        }

        if (rad == 180.0) {
            System.out.println(A + B);
        } else {
            rad = Math.toRadians(rad);
            double cosRad = Math.cos(rad);
            double res = Math.sqrt(Math.pow(A, 2) + Math.pow(B, 2) - (2 * A * B * cosRad));
            System.out.println(res);
        }
    }
}
