import java.util.Scanner;

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();

        double m1 = 6 * m;
        double h1 = 30 * h + 0.5 * m;
        double rc = Math.abs(m1 - h1);
        double c = 0;
        if (rc == 0) {
            System.out.printf("%.20f", Math.abs(a - b));
        }else if (rc == 180){
            System.out.printf("%.20f", a + b);
        }else{
            if(rc > 180){
                rc = 360 - rc;
            }
            c = a * a + b * b;
            if(rc != 90){
                rc = Math.toRadians(rc);
                c = c - 2 * a * b * Math.cos(rc);
            }
            c = Math.sqrt(c);
            System.out.printf("%.20f",c);
        }
    }
} import java.util.Scanner; Scanner 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();

        double m1 = 6 * m;
        double h1 = 30 * h + 0.5 * m;
        double rc = Math.abs(m1 - h1);
        double c = 0;
        if (rc == 0) {
            System.out.printf("%.20f", Math.abs(a - b));
        }else if (rc == 180){
            System.out.printf("%.20f", a + b);
        }else{
            if(rc > 180){
                rc = 360 - rc;
            }
            c = a * a + b * b;
            if(rc != 90){
                rc = Math.toRadians(rc);
                c = c - 2 * a * b * Math.cos(rc);
            }
            c = Math.sqrt(c);
            System.out.printf("%.20f",c);
        }
    }
} 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();

        double m1 = 6 * m;
        double h1 = 30 * h + 0.5 * m;
        double rc = Math.abs(m1 - h1);
        double c = 0;
        if (rc == 0) {
            System.out.printf("%.20f", Math.abs(a - b));
        }else if (rc == 180){
            System.out.printf("%.20f", a + b);
        }else{
            if(rc > 180){
                rc = 360 - rc;
            }
            c = a * a + b * b;
            if(rc != 90){
                rc = Math.toRadians(rc);
                c = c - 2 * a * b * Math.cos(rc);
            }
            c = Math.sqrt(c);
            System.out.printf("%.20f",c);
        }
    } main {
        Scanner sc = new Scanner(System.in);
        double a = sc.nextDouble();
        double b = sc.nextDouble();
        double h = sc.nextDouble();
        double m = sc.nextDouble();

        double m1 = 6 * m;
        double h1 = 30 * h + 0.5 * m;
        double rc = Math.abs(m1 - h1);
        double c = 0;
        if (rc == 0) {
            System.out.printf("%.20f", Math.abs(a - b));
        }else if (rc == 180){
            System.out.printf("%.20f", a + b);
        }else{
            if(rc > 180){
                rc = 360 - rc;
            }
            c = a * a + b * b;
            if(rc != 90){
                rc = Math.toRadians(rc);
                c = c - 2 * a * b * Math.cos(rc);
            }
            c = Math.sqrt(c);
            System.out.printf("%.20f",c);
        }
    } 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 double m1 = 6 * m; m1 6 * m 6 m double h1 = 30 * h + 0.5 * m; h1 30 * h + 0.5 * m 30 * h 30 h 0.5 * m 0.5 m double rc = Math.abs(m1 - h1); rc Math.abs(m1 - h1) Math.abs Math m1 - h1 m1 h1 double c = 0; c 0 if (rc == 0) {
            System.out.printf("%.20f", Math.abs(a - b));
        }else if (rc == 180){
            System.out.printf("%.20f", a + b);
        }else{
            if(rc > 180){
                rc = 360 - rc;
            }
            c = a * a + b * b;
            if(rc != 90){
                rc = Math.toRadians(rc);
                c = c - 2 * a * b * Math.cos(rc);
            }
            c = Math.sqrt(c);
            System.out.printf("%.20f",c);
        } rc == 0 rc 0 {
            System.out.printf("%.20f", Math.abs(a - b));
        } System.out.printf("%.20f", Math.abs(a - b)) System.out.printf System.out System System.out "%.20f" Math.abs(a - b) Math.abs Math a - b a b if (rc == 180){
            System.out.printf("%.20f", a + b);
        }else{
            if(rc > 180){
                rc = 360 - rc;
            }
            c = a * a + b * b;
            if(rc != 90){
                rc = Math.toRadians(rc);
                c = c - 2 * a * b * Math.cos(rc);
            }
            c = Math.sqrt(c);
            System.out.printf("%.20f",c);
        } rc == 180 rc 180 {
            System.out.printf("%.20f", a + b);
        } System.out.printf("%.20f", a + b) System.out.printf System.out System System.out "%.20f" a + b a b {
            if(rc > 180){
                rc = 360 - rc;
            }
            c = a * a + b * b;
            if(rc != 90){
                rc = Math.toRadians(rc);
                c = c - 2 * a * b * Math.cos(rc);
            }
            c = Math.sqrt(c);
            System.out.printf("%.20f",c);
        } if(rc > 180){
                rc = 360 - rc;
            } rc > 180 rc 180 {
                rc = 360 - rc;
            } rc = 360 - rc rc 360 - rc 360 rc c = a * a + b * b c a * a + b * b a * a a a b * b b b if(rc != 90){
                rc = Math.toRadians(rc);
                c = c - 2 * a * b * Math.cos(rc);
            } rc != 90 rc 90 {
                rc = Math.toRadians(rc);
                c = c - 2 * a * b * Math.cos(rc);
            } rc = Math.toRadians(rc) rc Math.toRadians(rc) Math.toRadians Math rc c = c - 2 * a * b * Math.cos(rc) c c - 2 * a * b * Math.cos(rc) c 2 * a * b * Math.cos(rc) b 2 * a * b * Math.cos(rc) 2 a b Math.cos(rc) Math.cos Math rc c = Math.sqrt(c) c Math.sqrt(c) Math.sqrt Math c System.out.printf("%.20f",c) System.out.printf System.out System System.out "%.20f" c 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();

        double m1 = 6 * m;
        double h1 = 30 * h + 0.5 * m;
        double rc = Math.abs(m1 - h1);
        double c = 0;
        if (rc == 0) {
            System.out.printf("%.20f", Math.abs(a - b));
        }else if (rc == 180){
            System.out.printf("%.20f", a + b);
        }else{
            if(rc > 180){
                rc = 360 - rc;
            }
            c = a * a + b * b;
            if(rc != 90){
                rc = Math.toRadians(rc);
                c = c - 2 * a * b * Math.cos(rc);
            }
            c = Math.sqrt(c);
            System.out.printf("%.20f",c);
        }
    }
} 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();

        double m1 = 6 * m;
        double h1 = 30 * h + 0.5 * m;
        double rc = Math.abs(m1 - h1);
        double c = 0;
        if (rc == 0) {
            System.out.printf("%.20f", Math.abs(a - b));
        }else if (rc == 180){
            System.out.printf("%.20f", a + b);
        }else{
            if(rc > 180){
                rc = 360 - rc;
            }
            c = a * a + b * b;
            if(rc != 90){
                rc = Math.toRadians(rc);
                c = c - 2 * a * b * Math.cos(rc);
            }
            c = Math.sqrt(c);
            System.out.printf("%.20f",c);
        }
    }
} Main
import java.util.Scanner;

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();

        double m1 = 6 * m;
        double h1 = 30 * h + 0.5 * m;
        double rc = Math.abs(m1 - h1);
        double c = 0;
        if (rc == 0) {
            System.out.printf("%.20f", Math.abs(a - b));
        }else if (rc == 180){
            System.out.printf("%.20f", a + b);
        }else{
            if(rc > 180){
                rc = 360 - rc;
            }
            c = a * a + b * b;
            if(rc != 90){
                rc = Math.toRadians(rc);
                c = c - 2 * a * b * Math.cos(rc);
            }
            c = Math.sqrt(c);
            System.out.printf("%.20f",c);
        }
    }
}