import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int H = scanner.nextInt();
        int M = scanner.nextInt();
        double degree = calculateAngle(H, M);
        double side = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(Math.toRadians(degree)));
        System.out.println(side);
    }

    static double calculateAngle(double h, double m) {
        double hour_angle = (0.5 * (h * 60 + m));
        double minute_angle = (6 * m);
        double angle = Math.abs(hour_angle - minute_angle);
        angle = Math.min(360 - angle, angle);
        return angle;
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int H = scanner.nextInt();
        int M = scanner.nextInt();
        double degree = calculateAngle(H, M);
        double side = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(Math.toRadians(degree)));
        System.out.println(side);
    }

    static double calculateAngle(double h, double m) {
        double hour_angle = (0.5 * (h * 60 + m));
        double minute_angle = (6 * m);
        double angle = Math.abs(hour_angle - minute_angle);
        angle = Math.min(360 - angle, angle);
        return angle;
    }
} Main public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int H = scanner.nextInt();
        int M = scanner.nextInt();
        double degree = calculateAngle(H, M);
        double side = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(Math.toRadians(degree)));
        System.out.println(side);
    } main {

        Scanner scanner = new Scanner(System.in);
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int H = scanner.nextInt();
        int M = scanner.nextInt();
        double degree = calculateAngle(H, M);
        double side = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(Math.toRadians(degree)));
        System.out.println(side);
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int A = scanner.nextInt(); A scanner.nextInt() scanner.nextInt scanner int B = scanner.nextInt(); B scanner.nextInt() scanner.nextInt scanner int H = scanner.nextInt(); H scanner.nextInt() scanner.nextInt scanner int M = scanner.nextInt(); M scanner.nextInt() scanner.nextInt scanner double degree = calculateAngle(H, M); degree calculateAngle(H, M) calculateAngle H M double side = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(Math.toRadians(degree))); side Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(Math.toRadians(degree))) Math.sqrt Math A * A + B * B - 2 * A * B * Math.cos(Math.toRadians(degree)) A * A + B * B A * A A A B * B B B 2 * A * B * Math.cos(Math.toRadians(degree)) B 2 * A * B * Math.cos(Math.toRadians(degree)) 2 A B Math.cos(Math.toRadians(degree)) Math.cos Math Math.toRadians(degree) Math.toRadians Math degree System.out.println(side) System.out.println System.out System System.out side String[] args args static double calculateAngle(double h, double m) {
        double hour_angle = (0.5 * (h * 60 + m));
        double minute_angle = (6 * m);
        double angle = Math.abs(hour_angle - minute_angle);
        angle = Math.min(360 - angle, angle);
        return angle;
    } calculateAngle {
        double hour_angle = (0.5 * (h * 60 + m));
        double minute_angle = (6 * m);
        double angle = Math.abs(hour_angle - minute_angle);
        angle = Math.min(360 - angle, angle);
        return angle;
    } double hour_angle = (0.5 * (h * 60 + m)); hour_angle (0.5 * (h * 60 + m)) 0.5 (h * 60 + m) h * 60 h 60 m double minute_angle = (6 * m); minute_angle (6 * m) 6 m double angle = Math.abs(hour_angle - minute_angle); angle Math.abs(hour_angle - minute_angle) Math.abs Math hour_angle - minute_angle hour_angle minute_angle angle = Math.min(360 - angle, angle) angle Math.min(360 - angle, angle) Math.min Math 360 - angle 360 angle angle return angle; angle double h h double m m public class Main {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int H = scanner.nextInt();
        int M = scanner.nextInt();
        double degree = calculateAngle(H, M);
        double side = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(Math.toRadians(degree)));
        System.out.println(side);
    }

    static double calculateAngle(double h, double m) {
        double hour_angle = (0.5 * (h * 60 + m));
        double minute_angle = (6 * m);
        double angle = Math.abs(hour_angle - minute_angle);
        angle = Math.min(360 - angle, angle);
        return angle;
    }
} public class Main {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int H = scanner.nextInt();
        int M = scanner.nextInt();
        double degree = calculateAngle(H, M);
        double side = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(Math.toRadians(degree)));
        System.out.println(side);
    }

    static double calculateAngle(double h, double m) {
        double hour_angle = (0.5 * (h * 60 + m));
        double minute_angle = (6 * m);
        double angle = Math.abs(hour_angle - minute_angle);
        angle = Math.min(360 - angle, angle);
        return angle;
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int H = scanner.nextInt();
        int M = scanner.nextInt();
        double degree = calculateAngle(H, M);
        double side = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(Math.toRadians(degree)));
        System.out.println(side);
    }

    static double calculateAngle(double h, double m) {
        double hour_angle = (0.5 * (h * 60 + m));
        double minute_angle = (6 * m);
        double angle = Math.abs(hour_angle - minute_angle);
        angle = Math.min(360 - angle, angle);
        return angle;
    }
}