import java.util.*;

class Main {
    public static void main(String[] args) {
        new Solver().run();
    }
}

class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();

        int H = sc.nextInt();
        int M = sc.nextInt();

        double hr = (H * 30) + 0.5 * M;
        double mr = (M * 6);
        
        double ra = Math.abs(hr - mr);
        //double ra = hr - mr;

        double ans = 0;

        ans = A * A +  B * B - (2 * A * B) * Math.cos(Math.toRadians(ra));

        System.out.println(Math.sqrt(ans));

        return;
    }

} import java.util.*; util.* java class Main {
    public static void main(String[] args) {
        new Solver().run();
    }
} Main public static void main(String[] args) {
        new Solver().run();
    } main {
        new Solver().run();
    } new Solver().run() new Solver().run new Solver() String[] args args class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();

        int H = sc.nextInt();
        int M = sc.nextInt();

        double hr = (H * 30) + 0.5 * M;
        double mr = (M * 6);
        
        double ra = Math.abs(hr - mr);
        //double ra = hr - mr;

        double ans = 0;

        ans = A * A +  B * B - (2 * A * B) * Math.cos(Math.toRadians(ra));

        System.out.println(Math.sqrt(ans));

        return;
    }

} Solver public void run() {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();

        int H = sc.nextInt();
        int M = sc.nextInt();

        double hr = (H * 30) + 0.5 * M;
        double mr = (M * 6);
        
        double ra = Math.abs(hr - mr);
        //double ra = hr - mr;

        double ans = 0;

        ans = A * A +  B * B - (2 * A * B) * Math.cos(Math.toRadians(ra));

        System.out.println(Math.sqrt(ans));

        return;
    } run {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();

        int H = sc.nextInt();
        int M = sc.nextInt();

        double hr = (H * 30) + 0.5 * M;
        double mr = (M * 6);
        
        double ra = Math.abs(hr - mr);
        //double ra = hr - mr;

        double ans = 0;

        ans = A * A +  B * B - (2 * A * B) * Math.cos(Math.toRadians(ra));

        System.out.println(Math.sqrt(ans));

        return;
    } 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 = (H * 30) + 0.5 * M; hr (H * 30) + 0.5 * M (H * 30) H 30 0.5 * M 0.5 M double mr = (M * 6); mr (M * 6) M 6 double ra = Math.abs(hr - mr); ra Math.abs(hr - mr) Math.abs Math hr - mr hr mr double ans = 0; ans 0 ans = A * A +  B * B - (2 * A * B) * Math.cos(Math.toRadians(ra)) ans A * A +  B * B - (2 * A * B) * Math.cos(Math.toRadians(ra)) A * A +  B * B A * A A A B * B B B (2 * A * B) * Math.cos(Math.toRadians(ra)) (2 * A * B) 2 * A * B 2 A B Math.cos(Math.toRadians(ra)) Math.cos Math Math.toRadians(ra) Math.toRadians Math ra System.out.println(Math.sqrt(ans)) System.out.println System.out System System.out Math.sqrt(ans) Math.sqrt Math ans return;
import java.util.*;

class Main {
    public static void main(String[] args) {
        new Solver().run();
    }
}

class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();

        int H = sc.nextInt();
        int M = sc.nextInt();

        double hr = (H * 30) + 0.5 * M;
        double mr = (M * 6);
        
        double ra = Math.abs(hr - mr);
        //double ra = hr - mr;

        double ans = 0;

        ans = A * A +  B * B - (2 * A * B) * Math.cos(Math.toRadians(ra));

        System.out.println(Math.sqrt(ans));

        return;
    }

}