import java.util.*;

public class Main {
    public static void main(String[] args ) throws Exception {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int H = sc.nextInt();
        int M = sc.nextInt();

        //進度
        double tan = 0;
        tan = (H * 30) + (M * 0.5);
        double tyo = 0;
        tyo = (M * 6);

        // 角度
        double kaku = 0;
        kaku = (tan - tyo);

        // ラジアン
        double radi = Math.toRadians(kaku);
        
        // C
        double C = 0;
        C = Math.cos(radi);

        // 余弦定理
        C = Math.sqrt(((A*A) + (B*B)) - ((2*A*B)*C));
        System.out.println(C);

    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args ) throws Exception {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int H = sc.nextInt();
        int M = sc.nextInt();

        //進度
        double tan = 0;
        tan = (H * 30) + (M * 0.5);
        double tyo = 0;
        tyo = (M * 6);

        // 角度
        double kaku = 0;
        kaku = (tan - tyo);

        // ラジアン
        double radi = Math.toRadians(kaku);
        
        // C
        double C = 0;
        C = Math.cos(radi);

        // 余弦定理
        C = Math.sqrt(((A*A) + (B*B)) - ((2*A*B)*C));
        System.out.println(C);

    }
} Main public static void main(String[] args ) throws Exception {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int H = sc.nextInt();
        int M = sc.nextInt();

        //進度
        double tan = 0;
        tan = (H * 30) + (M * 0.5);
        double tyo = 0;
        tyo = (M * 6);

        // 角度
        double kaku = 0;
        kaku = (tan - tyo);

        // ラジアン
        double radi = Math.toRadians(kaku);
        
        // C
        double C = 0;
        C = Math.cos(radi);

        // 余弦定理
        C = Math.sqrt(((A*A) + (B*B)) - ((2*A*B)*C));
        System.out.println(C);

    } main {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int H = sc.nextInt();
        int M = sc.nextInt();

        //進度
        double tan = 0;
        tan = (H * 30) + (M * 0.5);
        double tyo = 0;
        tyo = (M * 6);

        // 角度
        double kaku = 0;
        kaku = (tan - tyo);

        // ラジアン
        double radi = Math.toRadians(kaku);
        
        // C
        double C = 0;
        C = Math.cos(radi);

        // 余弦定理
        C = Math.sqrt(((A*A) + (B*B)) - ((2*A*B)*C));
        System.out.println(C);

    } 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 tan = 0; tan 0 tan = (H * 30) + (M * 0.5) tan (H * 30) + (M * 0.5) (H * 30) H 30 (M * 0.5) M 0.5 double tyo = 0; tyo 0 tyo = (M * 6) tyo (M * 6) M 6 double kaku = 0; kaku 0 kaku = (tan - tyo) kaku (tan - tyo) tan tyo double radi = Math.toRadians(kaku); radi Math.toRadians(kaku) Math.toRadians Math kaku double C = 0; C 0 C = Math.cos(radi) C Math.cos(radi) Math.cos Math radi C = Math.sqrt(((A*A) + (B*B)) - ((2*A*B)*C)) C Math.sqrt(((A*A) + (B*B)) - ((2*A*B)*C)) Math.sqrt Math ((A*A) + (B*B)) - ((2*A*B)*C) ((A*A) + (B*B)) (A*A) A A (B*B) B B ((2*A*B)*C) (2*A*B) 2*A*B 2 A B C System.out.println(C) System.out.println System.out System System.out C String[] args args public class Main {
    public static void main(String[] args ) throws Exception {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int H = sc.nextInt();
        int M = sc.nextInt();

        //進度
        double tan = 0;
        tan = (H * 30) + (M * 0.5);
        double tyo = 0;
        tyo = (M * 6);

        // 角度
        double kaku = 0;
        kaku = (tan - tyo);

        // ラジアン
        double radi = Math.toRadians(kaku);
        
        // C
        double C = 0;
        C = Math.cos(radi);

        // 余弦定理
        C = Math.sqrt(((A*A) + (B*B)) - ((2*A*B)*C));
        System.out.println(C);

    }
} public class Main {
    public static void main(String[] args ) throws Exception {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int H = sc.nextInt();
        int M = sc.nextInt();

        //進度
        double tan = 0;
        tan = (H * 30) + (M * 0.5);
        double tyo = 0;
        tyo = (M * 6);

        // 角度
        double kaku = 0;
        kaku = (tan - tyo);

        // ラジアン
        double radi = Math.toRadians(kaku);
        
        // C
        double C = 0;
        C = Math.cos(radi);

        // 余弦定理
        C = Math.sqrt(((A*A) + (B*B)) - ((2*A*B)*C));
        System.out.println(C);

    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args ) throws Exception {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int H = sc.nextInt();
        int M = sc.nextInt();

        //進度
        double tan = 0;
        tan = (H * 30) + (M * 0.5);
        double tyo = 0;
        tyo = (M * 6);

        // 角度
        double kaku = 0;
        kaku = (tan - tyo);

        // ラジアン
        double radi = Math.toRadians(kaku);
        
        // C
        double C = 0;
        C = Math.cos(radi);

        // 余弦定理
        C = Math.sqrt(((A*A) + (B*B)) - ((2*A*B)*C));
        System.out.println(C);

    }
}
