import java.util.*;
public class Main {
     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 HR = 30 * H + M * 0.5;
        double MR = 360 / 60 * M;

        double r = Math.abs(HR - MR);
        double cos = Math.cos(Math.toRadians(r));
        double result = Math.pow(A, 2) + Math.pow(B, 2) - 2 * A * B * cos;
        result = Math.sqrt(result);
       
       
        System.out.println(result);
    }
} import java.util.*; util.* java public class Main {
     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 HR = 30 * H + M * 0.5;
        double MR = 360 / 60 * M;

        double r = Math.abs(HR - MR);
        double cos = Math.cos(Math.toRadians(r));
        double result = Math.pow(A, 2) + Math.pow(B, 2) - 2 * A * B * cos;
        result = Math.sqrt(result);
       
       
        System.out.println(result);
    }
} Main 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 HR = 30 * H + M * 0.5;
        double MR = 360 / 60 * M;

        double r = Math.abs(HR - MR);
        double cos = Math.cos(Math.toRadians(r));
        double result = Math.pow(A, 2) + Math.pow(B, 2) - 2 * A * B * cos;
        result = Math.sqrt(result);
       
       
        System.out.println(result);
    } main {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int H = sc.nextInt();
        int M = sc.nextInt();

        double HR = 30 * H + M * 0.5;
        double MR = 360 / 60 * M;

        double r = Math.abs(HR - MR);
        double cos = Math.cos(Math.toRadians(r));
        double result = Math.pow(A, 2) + Math.pow(B, 2) - 2 * A * B * cos;
        result = Math.sqrt(result);
       
       
        System.out.println(result);
    } 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 HR = 30 * H + M * 0.5; HR 30 * H + M * 0.5 30 * H 30 H M * 0.5 M 0.5 double MR = 360 / 60 * M; MR 360 / 60 * M 360 / 60 360 60 M double r = Math.abs(HR - MR); r Math.abs(HR - MR) Math.abs Math HR - MR HR MR double cos = Math.cos(Math.toRadians(r)); cos Math.cos(Math.toRadians(r)) Math.cos Math Math.toRadians(r) Math.toRadians Math r double result = Math.pow(A, 2) + Math.pow(B, 2) - 2 * A * B * cos; result Math.pow(A, 2) + Math.pow(B, 2) - 2 * A * B * cos 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 * cos B 2 * A * B * cos 2 A B cos result = Math.sqrt(result) result Math.sqrt(result) Math.sqrt Math result System.out.println(result) System.out.println System.out System System.out result String[] args args public class Main {
     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 HR = 30 * H + M * 0.5;
        double MR = 360 / 60 * M;

        double r = Math.abs(HR - MR);
        double cos = Math.cos(Math.toRadians(r));
        double result = Math.pow(A, 2) + Math.pow(B, 2) - 2 * A * B * cos;
        result = Math.sqrt(result);
       
       
        System.out.println(result);
    }
} public class Main {
     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 HR = 30 * H + M * 0.5;
        double MR = 360 / 60 * M;

        double r = Math.abs(HR - MR);
        double cos = Math.cos(Math.toRadians(r));
        double result = Math.pow(A, 2) + Math.pow(B, 2) - 2 * A * B * cos;
        result = Math.sqrt(result);
       
       
        System.out.println(result);
    }
} Main
import java.util.*;
public class Main {
     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 HR = 30 * H + M * 0.5;
        double MR = 360 / 60 * M;

        double r = Math.abs(HR - MR);
        double cos = Math.cos(Math.toRadians(r));
        double result = Math.pow(A, 2) + Math.pow(B, 2) - 2 * A * B * cos;
        result = Math.sqrt(result);
       
       
        System.out.println(result);
    }
}