import java.util.Scanner;

public class Main {
    // １分間に長針が動く角度
    private static double LONG_ANGLE  = 0.5;
    // １分間に短針が動く角度
    private static double SHORT_ANGLE = 6.0;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        // 長針の長さ
        int a = sc.nextInt();
        // 短針の長さ
        int b = sc.nextInt();

        int h = sc.nextInt();
        int m = sc.nextInt();

        double angleH = LONG_ANGLE  * (h * 60 + m);
        double angleM = SHORT_ANGLE * m;
        double angle = 0;
        if (angleH > angleM) {
            angle = angleH - angleM;
        } else {
            angle = angleM - angleH;
        }

        System.out.println(
                Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(Math.toRadians(angle))));
    }
} import java.util.Scanner; Scanner java.util public class Main {
    // １分間に長針が動く角度
    private static double LONG_ANGLE  = 0.5;
    // １分間に短針が動く角度
    private static double SHORT_ANGLE = 6.0;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        // 長針の長さ
        int a = sc.nextInt();
        // 短針の長さ
        int b = sc.nextInt();

        int h = sc.nextInt();
        int m = sc.nextInt();

        double angleH = LONG_ANGLE  * (h * 60 + m);
        double angleM = SHORT_ANGLE * m;
        double angle = 0;
        if (angleH > angleM) {
            angle = angleH - angleM;
        } else {
            angle = angleM - angleH;
        }

        System.out.println(
                Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(Math.toRadians(angle))));
    }
} Main // １分間に長針が動く角度
    private static double LONG_ANGLE  = 0.5; LONG_ANGLE 0.5 // １分間に短針が動く角度
    private static double SHORT_ANGLE = 6.0; SHORT_ANGLE 6.0 public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        // 長針の長さ
        int a = sc.nextInt();
        // 短針の長さ
        int b = sc.nextInt();

        int h = sc.nextInt();
        int m = sc.nextInt();

        double angleH = LONG_ANGLE  * (h * 60 + m);
        double angleM = SHORT_ANGLE * m;
        double angle = 0;
        if (angleH > angleM) {
            angle = angleH - angleM;
        } else {
            angle = angleM - angleH;
        }

        System.out.println(
                Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(Math.toRadians(angle))));
    } main {
        Scanner sc = new Scanner(System.in);

        // 長針の長さ
        int a = sc.nextInt();
        // 短針の長さ
        int b = sc.nextInt();

        int h = sc.nextInt();
        int m = sc.nextInt();

        double angleH = LONG_ANGLE  * (h * 60 + m);
        double angleM = SHORT_ANGLE * m;
        double angle = 0;
        if (angleH > angleM) {
            angle = angleH - angleM;
        } else {
            angle = angleM - angleH;
        }

        System.out.println(
                Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(Math.toRadians(angle))));
    } 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 double angleH = LONG_ANGLE  * (h * 60 + m); angleH LONG_ANGLE  * (h * 60 + m) LONG_ANGLE (h * 60 + m) h * 60 h 60 m double angleM = SHORT_ANGLE * m; angleM SHORT_ANGLE * m SHORT_ANGLE m double angle = 0; angle 0 if (angleH > angleM) {
            angle = angleH - angleM;
        } else {
            angle = angleM - angleH;
        } angleH > angleM angleH angleM {
            angle = angleH - angleM;
        } angle = angleH - angleM angle angleH - angleM angleH angleM {
            angle = angleM - angleH;
        } angle = angleM - angleH angle angleM - angleH angleM angleH System.out.println(
                Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(Math.toRadians(angle)))) System.out.println System.out System System.out Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(Math.toRadians(angle))) Math.sqrt Math a * a + b * b - 2 * a * b * Math.cos(Math.toRadians(angle)) a * a + b * b a * a a a b * b b b 2 * a * b * Math.cos(Math.toRadians(angle)) b 2 * a * b * Math.cos(Math.toRadians(angle)) 2 a b Math.cos(Math.toRadians(angle)) Math.cos Math Math.toRadians(angle) Math.toRadians Math angle String[] args args public class Main {
    // １分間に長針が動く角度
    private static double LONG_ANGLE  = 0.5;
    // １分間に短針が動く角度
    private static double SHORT_ANGLE = 6.0;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        // 長針の長さ
        int a = sc.nextInt();
        // 短針の長さ
        int b = sc.nextInt();

        int h = sc.nextInt();
        int m = sc.nextInt();

        double angleH = LONG_ANGLE  * (h * 60 + m);
        double angleM = SHORT_ANGLE * m;
        double angle = 0;
        if (angleH > angleM) {
            angle = angleH - angleM;
        } else {
            angle = angleM - angleH;
        }

        System.out.println(
                Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(Math.toRadians(angle))));
    }
} public class Main {
    // １分間に長針が動く角度
    private static double LONG_ANGLE  = 0.5;
    // １分間に短針が動く角度
    private static double SHORT_ANGLE = 6.0;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        // 長針の長さ
        int a = sc.nextInt();
        // 短針の長さ
        int b = sc.nextInt();

        int h = sc.nextInt();
        int m = sc.nextInt();

        double angleH = LONG_ANGLE  * (h * 60 + m);
        double angleM = SHORT_ANGLE * m;
        double angle = 0;
        if (angleH > angleM) {
            angle = angleH - angleM;
        } else {
            angle = angleM - angleH;
        }

        System.out.println(
                Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(Math.toRadians(angle))));
    }
} Main
import java.util.Scanner;

public class Main {
    // １分間に長針が動く角度
    private static double LONG_ANGLE  = 0.5;
    // １分間に短針が動く角度
    private static double SHORT_ANGLE = 6.0;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        // 長針の長さ
        int a = sc.nextInt();
        // 短針の長さ
        int b = sc.nextInt();

        int h = sc.nextInt();
        int m = sc.nextInt();

        double angleH = LONG_ANGLE  * (h * 60 + m);
        double angleM = SHORT_ANGLE * m;
        double angle = 0;
        if (angleH > angleM) {
            angle = angleH - angleM;
        } else {
            angle = angleM - angleH;
        }

        System.out.println(
                Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(Math.toRadians(angle))));
    }
}