import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner scn = new Scanner(System.in);
        double a = scn.nextInt();
        double b = scn.nextInt();
        double h = scn.nextInt();
        double m = scn.nextInt();

        double ans = 0;
        double r = Math.abs(((((h * 60) + m) / 2) - (m * 6)));

        if ( r == 0) {
            System.out.println(Math.abs(a - b));
        } else if (r == 180) {
            System.out.println(a + b);
        } else {
            ans = Math.sqrt((a * a) + (b * b) - (2 * a * b * Math.cos(Math.toRadians(r))));
            System.out.println(ans);
        }

        scn.close();
    }
} import java.util.*; util.* java public class Main {
    public static void main(String args[]) {
        Scanner scn = new Scanner(System.in);
        double a = scn.nextInt();
        double b = scn.nextInt();
        double h = scn.nextInt();
        double m = scn.nextInt();

        double ans = 0;
        double r = Math.abs(((((h * 60) + m) / 2) - (m * 6)));

        if ( r == 0) {
            System.out.println(Math.abs(a - b));
        } else if (r == 180) {
            System.out.println(a + b);
        } else {
            ans = Math.sqrt((a * a) + (b * b) - (2 * a * b * Math.cos(Math.toRadians(r))));
            System.out.println(ans);
        }

        scn.close();
    }
} Main public static void main(String args[]) {
        Scanner scn = new Scanner(System.in);
        double a = scn.nextInt();
        double b = scn.nextInt();
        double h = scn.nextInt();
        double m = scn.nextInt();

        double ans = 0;
        double r = Math.abs(((((h * 60) + m) / 2) - (m * 6)));

        if ( r == 0) {
            System.out.println(Math.abs(a - b));
        } else if (r == 180) {
            System.out.println(a + b);
        } else {
            ans = Math.sqrt((a * a) + (b * b) - (2 * a * b * Math.cos(Math.toRadians(r))));
            System.out.println(ans);
        }

        scn.close();
    } main {
        Scanner scn = new Scanner(System.in);
        double a = scn.nextInt();
        double b = scn.nextInt();
        double h = scn.nextInt();
        double m = scn.nextInt();

        double ans = 0;
        double r = Math.abs(((((h * 60) + m) / 2) - (m * 6)));

        if ( r == 0) {
            System.out.println(Math.abs(a - b));
        } else if (r == 180) {
            System.out.println(a + b);
        } else {
            ans = Math.sqrt((a * a) + (b * b) - (2 * a * b * Math.cos(Math.toRadians(r))));
            System.out.println(ans);
        }

        scn.close();
    } Scanner scn = new Scanner(System.in); scn new Scanner(System.in) double a = scn.nextInt(); a scn.nextInt() scn.nextInt scn double b = scn.nextInt(); b scn.nextInt() scn.nextInt scn double h = scn.nextInt(); h scn.nextInt() scn.nextInt scn double m = scn.nextInt(); m scn.nextInt() scn.nextInt scn double ans = 0; ans 0 double r = Math.abs(((((h * 60) + m) / 2) - (m * 6))); r Math.abs(((((h * 60) + m) / 2) - (m * 6))) Math.abs Math ((((h * 60) + m) / 2) - (m * 6)) (((h * 60) + m) / 2) ((h * 60) + m) (h * 60) h 60 m 2 (m * 6) m 6 if ( r == 0) {
            System.out.println(Math.abs(a - b));
        } else if (r == 180) {
            System.out.println(a + b);
        } else {
            ans = Math.sqrt((a * a) + (b * b) - (2 * a * b * Math.cos(Math.toRadians(r))));
            System.out.println(ans);
        } r == 0 r 0 {
            System.out.println(Math.abs(a - b));
        } System.out.println(Math.abs(a - b)) System.out.println System.out System System.out Math.abs(a - b) Math.abs Math a - b a b if (r == 180) {
            System.out.println(a + b);
        } else {
            ans = Math.sqrt((a * a) + (b * b) - (2 * a * b * Math.cos(Math.toRadians(r))));
            System.out.println(ans);
        } r == 180 r 180 {
            System.out.println(a + b);
        } System.out.println(a + b) System.out.println System.out System System.out a + b a b {
            ans = Math.sqrt((a * a) + (b * b) - (2 * a * b * Math.cos(Math.toRadians(r))));
            System.out.println(ans);
        } ans = Math.sqrt((a * a) + (b * b) - (2 * a * b * Math.cos(Math.toRadians(r)))) ans Math.sqrt((a * a) + (b * b) - (2 * a * b * Math.cos(Math.toRadians(r)))) Math.sqrt Math (a * a) + (b * b) - (2 * a * b * Math.cos(Math.toRadians(r))) (a * a) + (b * b) (a * a) a a (b * b) b b (2 * a * b * Math.cos(Math.toRadians(r))) b 2 * a * b * Math.cos(Math.toRadians(r)) 2 a b Math.cos(Math.toRadians(r)) Math.cos Math Math.toRadians(r) Math.toRadians Math r System.out.println(ans) System.out.println System.out System System.out ans scn.close() scn.close scn String args[] args public class Main {
    public static void main(String args[]) {
        Scanner scn = new Scanner(System.in);
        double a = scn.nextInt();
        double b = scn.nextInt();
        double h = scn.nextInt();
        double m = scn.nextInt();

        double ans = 0;
        double r = Math.abs(((((h * 60) + m) / 2) - (m * 6)));

        if ( r == 0) {
            System.out.println(Math.abs(a - b));
        } else if (r == 180) {
            System.out.println(a + b);
        } else {
            ans = Math.sqrt((a * a) + (b * b) - (2 * a * b * Math.cos(Math.toRadians(r))));
            System.out.println(ans);
        }

        scn.close();
    }
} public class Main {
    public static void main(String args[]) {
        Scanner scn = new Scanner(System.in);
        double a = scn.nextInt();
        double b = scn.nextInt();
        double h = scn.nextInt();
        double m = scn.nextInt();

        double ans = 0;
        double r = Math.abs(((((h * 60) + m) / 2) - (m * 6)));

        if ( r == 0) {
            System.out.println(Math.abs(a - b));
        } else if (r == 180) {
            System.out.println(a + b);
        } else {
            ans = Math.sqrt((a * a) + (b * b) - (2 * a * b * Math.cos(Math.toRadians(r))));
            System.out.println(ans);
        }

        scn.close();
    }
} Main
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner scn = new Scanner(System.in);
        double a = scn.nextInt();
        double b = scn.nextInt();
        double h = scn.nextInt();
        double m = scn.nextInt();

        double ans = 0;
        double r = Math.abs(((((h * 60) + m) / 2) - (m * 6)));

        if ( r == 0) {
            System.out.println(Math.abs(a - b));
        } else if (r == 180) {
            System.out.println(a + b);
        } else {
            ans = Math.sqrt((a * a) + (b * b) - (2 * a * b * Math.cos(Math.toRadians(r))));
            System.out.println(ans);
        }

        scn.close();
    }
}