import java.util.Scanner;

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();
        sc.close();

        double hDegree = (h*60+m)*0.5;
        double mDegree = m*6;
        double degree = Math.abs(hDegree-mDegree);

        double ans = Math.sqrt(Math.pow(a,2)+Math.pow(b,2)-2*a*b*Math.cos(Math.toRadians(degree)));
        System.out.println(ans);

    }
} import java.util.Scanner; Scanner 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();
        sc.close();

        double hDegree = (h*60+m)*0.5;
        double mDegree = m*6;
        double degree = Math.abs(hDegree-mDegree);

        double ans = Math.sqrt(Math.pow(a,2)+Math.pow(b,2)-2*a*b*Math.cos(Math.toRadians(degree)));
        System.out.println(ans);

    }
} 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();
        sc.close();

        double hDegree = (h*60+m)*0.5;
        double mDegree = m*6;
        double degree = Math.abs(hDegree-mDegree);

        double ans = Math.sqrt(Math.pow(a,2)+Math.pow(b,2)-2*a*b*Math.cos(Math.toRadians(degree)));
        System.out.println(ans);

    } main {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();
        sc.close();

        double hDegree = (h*60+m)*0.5;
        double mDegree = m*6;
        double degree = Math.abs(hDegree-mDegree);

        double ans = Math.sqrt(Math.pow(a,2)+Math.pow(b,2)-2*a*b*Math.cos(Math.toRadians(degree)));
        System.out.println(ans);

    } 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 sc.close() sc.close sc double hDegree = (h*60+m)*0.5; hDegree (h*60+m)*0.5 (h*60+m) h*60 h 60 m 0.5 double mDegree = m*6; mDegree m*6 m 6 double degree = Math.abs(hDegree-mDegree); degree Math.abs(hDegree-mDegree) Math.abs Math hDegree-mDegree hDegree mDegree double ans = Math.sqrt(Math.pow(a,2)+Math.pow(b,2)-2*a*b*Math.cos(Math.toRadians(degree))); ans Math.sqrt(Math.pow(a,2)+Math.pow(b,2)-2*a*b*Math.cos(Math.toRadians(degree))) Math.sqrt Math Math.pow(a,2)+Math.pow(b,2)-2*a*b*Math.cos(Math.toRadians(degree)) 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(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(ans) System.out.println System.out System System.out ans 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();
        sc.close();

        double hDegree = (h*60+m)*0.5;
        double mDegree = m*6;
        double degree = Math.abs(hDegree-mDegree);

        double ans = Math.sqrt(Math.pow(a,2)+Math.pow(b,2)-2*a*b*Math.cos(Math.toRadians(degree)));
        System.out.println(ans);

    }
} 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();
        sc.close();

        double hDegree = (h*60+m)*0.5;
        double mDegree = m*6;
        double degree = Math.abs(hDegree-mDegree);

        double ans = Math.sqrt(Math.pow(a,2)+Math.pow(b,2)-2*a*b*Math.cos(Math.toRadians(degree)));
        System.out.println(ans);

    }
} Main
import java.util.Scanner;

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();
        sc.close();

        double hDegree = (h*60+m)*0.5;
        double mDegree = m*6;
        double degree = Math.abs(hDegree-mDegree);

        double ans = Math.sqrt(Math.pow(a,2)+Math.pow(b,2)-2*a*b*Math.cos(Math.toRadians(degree)));
        System.out.println(ans);

    }
}
