
import java.util.*;

public class Main {
    public static void main(final String[] args) {
        final Scanner sc = new Scanner(System.in);
        // 整数の入力
        // final int a = sc.nextInt();
        // 文字列の入力
        // final String s1 = sc.next();
        final double a = sc.nextInt();
        final double b = sc.nextInt();
        final double h = sc.nextInt();
        final double m = sc.nextInt();
        double h_deg = h * 360 / 12 + m * 360 / 12 / 60;
        double m_deg = m * 360 / 60;
        sc.close();
        double result = 0;
        result = Math.pow(
                (Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(Math.toRadians(Math.abs(h_deg - m_deg)))), 0.5);

        System.out.println(result);
    }
} import java.util.*; util.* java public class Main {
    public static void main(final String[] args) {
        final Scanner sc = new Scanner(System.in);
        // 整数の入力
        // final int a = sc.nextInt();
        // 文字列の入力
        // final String s1 = sc.next();
        final double a = sc.nextInt();
        final double b = sc.nextInt();
        final double h = sc.nextInt();
        final double m = sc.nextInt();
        double h_deg = h * 360 / 12 + m * 360 / 12 / 60;
        double m_deg = m * 360 / 60;
        sc.close();
        double result = 0;
        result = Math.pow(
                (Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(Math.toRadians(Math.abs(h_deg - m_deg)))), 0.5);

        System.out.println(result);
    }
} Main public static void main(final String[] args) {
        final Scanner sc = new Scanner(System.in);
        // 整数の入力
        // final int a = sc.nextInt();
        // 文字列の入力
        // final String s1 = sc.next();
        final double a = sc.nextInt();
        final double b = sc.nextInt();
        final double h = sc.nextInt();
        final double m = sc.nextInt();
        double h_deg = h * 360 / 12 + m * 360 / 12 / 60;
        double m_deg = m * 360 / 60;
        sc.close();
        double result = 0;
        result = Math.pow(
                (Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(Math.toRadians(Math.abs(h_deg - m_deg)))), 0.5);

        System.out.println(result);
    } main {
        final Scanner sc = new Scanner(System.in);
        // 整数の入力
        // final int a = sc.nextInt();
        // 文字列の入力
        // final String s1 = sc.next();
        final double a = sc.nextInt();
        final double b = sc.nextInt();
        final double h = sc.nextInt();
        final double m = sc.nextInt();
        double h_deg = h * 360 / 12 + m * 360 / 12 / 60;
        double m_deg = m * 360 / 60;
        sc.close();
        double result = 0;
        result = Math.pow(
                (Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(Math.toRadians(Math.abs(h_deg - m_deg)))), 0.5);

        System.out.println(result);
    } final Scanner sc = new Scanner(System.in); sc new Scanner(System.in) final double a = sc.nextInt(); a sc.nextInt() sc.nextInt sc final double b = sc.nextInt(); b sc.nextInt() sc.nextInt sc final double h = sc.nextInt(); h sc.nextInt() sc.nextInt sc final double m = sc.nextInt(); m sc.nextInt() sc.nextInt sc double h_deg = h * 360 / 12 + m * 360 / 12 / 60; h_deg h * 360 / 12 + m * 360 / 12 / 60 h * 360 / 12 h * 360 h 360 12 m * 360 / 12 / 60 m * 360 / 12 / 60 m * 360 m 360 12 60 double m_deg = m * 360 / 60; m_deg m * 360 / 60 m * 360 m 360 60 sc.close() sc.close sc double result = 0; result 0 result = Math.pow(
                (Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(Math.toRadians(Math.abs(h_deg - m_deg)))), 0.5) result Math.pow(
                (Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(Math.toRadians(Math.abs(h_deg - m_deg)))), 0.5) Math.pow Math (Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(Math.toRadians(Math.abs(h_deg - m_deg)))) 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 * Math.cos(Math.toRadians(Math.abs(h_deg - m_deg))) b 2 * a * b * Math.cos(Math.toRadians(Math.abs(h_deg - m_deg))) 2 a b Math.cos(Math.toRadians(Math.abs(h_deg - m_deg))) Math.cos Math Math.toRadians(Math.abs(h_deg - m_deg)) Math.toRadians Math Math.abs(h_deg - m_deg) Math.abs Math h_deg - m_deg h_deg m_deg 0.5 System.out.println(result) System.out.println System.out System System.out result final String[] args args public class Main {
    public static void main(final String[] args) {
        final Scanner sc = new Scanner(System.in);
        // 整数の入力
        // final int a = sc.nextInt();
        // 文字列の入力
        // final String s1 = sc.next();
        final double a = sc.nextInt();
        final double b = sc.nextInt();
        final double h = sc.nextInt();
        final double m = sc.nextInt();
        double h_deg = h * 360 / 12 + m * 360 / 12 / 60;
        double m_deg = m * 360 / 60;
        sc.close();
        double result = 0;
        result = Math.pow(
                (Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(Math.toRadians(Math.abs(h_deg - m_deg)))), 0.5);

        System.out.println(result);
    }
} public class Main {
    public static void main(final String[] args) {
        final Scanner sc = new Scanner(System.in);
        // 整数の入力
        // final int a = sc.nextInt();
        // 文字列の入力
        // final String s1 = sc.next();
        final double a = sc.nextInt();
        final double b = sc.nextInt();
        final double h = sc.nextInt();
        final double m = sc.nextInt();
        double h_deg = h * 360 / 12 + m * 360 / 12 / 60;
        double m_deg = m * 360 / 60;
        sc.close();
        double result = 0;
        result = Math.pow(
                (Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(Math.toRadians(Math.abs(h_deg - m_deg)))), 0.5);

        System.out.println(result);
    }
} Main

import java.util.*;

public class Main {
    public static void main(final String[] args) {
        final Scanner sc = new Scanner(System.in);
        // 整数の入力
        // final int a = sc.nextInt();
        // 文字列の入力
        // final String s1 = sc.next();
        final double a = sc.nextInt();
        final double b = sc.nextInt();
        final double h = sc.nextInt();
        final double m = sc.nextInt();
        double h_deg = h * 360 / 12 + m * 360 / 12 / 60;
        double m_deg = m * 360 / 60;
        sc.close();
        double result = 0;
        result = Math.pow(
                (Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(Math.toRadians(Math.abs(h_deg - m_deg)))), 0.5);

        System.out.println(result);
    }
}