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

        double t = (double) H*5 + (double) M/12;
        double sa = Math.abs(t - M);

        if (sa > 30) {
            sa = 60 - sa;
        }

        sa *= 6.0;

        double ans = Math.pow(A, 2) + Math.pow(B, 2) - 2.0 * A * B * Math.cos(Math.toRadians(sa));

        System.out.println(Math.sqrt(ans));
    }
} 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();
        sc.nextLine();

        double t = (double) H*5 + (double) M/12;
        double sa = Math.abs(t - M);

        if (sa > 30) {
            sa = 60 - sa;
        }

        sa *= 6.0;

        double ans = Math.pow(A, 2) + Math.pow(B, 2) - 2.0 * A * B * Math.cos(Math.toRadians(sa));

        System.out.println(Math.sqrt(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.nextLine();

        double t = (double) H*5 + (double) M/12;
        double sa = Math.abs(t - M);

        if (sa > 30) {
            sa = 60 - sa;
        }

        sa *= 6.0;

        double ans = Math.pow(A, 2) + Math.pow(B, 2) - 2.0 * A * B * Math.cos(Math.toRadians(sa));

        System.out.println(Math.sqrt(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.nextLine();

        double t = (double) H*5 + (double) M/12;
        double sa = Math.abs(t - M);

        if (sa > 30) {
            sa = 60 - sa;
        }

        sa *= 6.0;

        double ans = Math.pow(A, 2) + Math.pow(B, 2) - 2.0 * A * B * Math.cos(Math.toRadians(sa));

        System.out.println(Math.sqrt(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.nextLine() sc.nextLine sc double t = (double) H*5 + (double) M/12; t (double) H*5 + (double) M/12 (double) H*5 (double) H 5 (double) M/12 (double) M 12 double sa = Math.abs(t - M); sa Math.abs(t - M) Math.abs Math t - M t M if (sa > 30) {
            sa = 60 - sa;
        } sa > 30 sa 30 {
            sa = 60 - sa;
        } sa = 60 - sa sa 60 - sa 60 sa sa *= 6.0 sa 6.0 double ans = Math.pow(A, 2) + Math.pow(B, 2) - 2.0 * A * B * Math.cos(Math.toRadians(sa)); ans Math.pow(A, 2) + Math.pow(B, 2) - 2.0 * A * B * Math.cos(Math.toRadians(sa)) 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.0 * A * B * Math.cos(Math.toRadians(sa)) B 2.0 * A * B * Math.cos(Math.toRadians(sa)) 2.0 A B Math.cos(Math.toRadians(sa)) Math.cos Math Math.toRadians(sa) Math.toRadians Math sa System.out.println(Math.sqrt(ans)) System.out.println System.out System System.out Math.sqrt(ans) Math.sqrt Math 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.nextLine();

        double t = (double) H*5 + (double) M/12;
        double sa = Math.abs(t - M);

        if (sa > 30) {
            sa = 60 - sa;
        }

        sa *= 6.0;

        double ans = Math.pow(A, 2) + Math.pow(B, 2) - 2.0 * A * B * Math.cos(Math.toRadians(sa));

        System.out.println(Math.sqrt(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.nextLine();

        double t = (double) H*5 + (double) M/12;
        double sa = Math.abs(t - M);

        if (sa > 30) {
            sa = 60 - sa;
        }

        sa *= 6.0;

        double ans = Math.pow(A, 2) + Math.pow(B, 2) - 2.0 * A * B * Math.cos(Math.toRadians(sa));

        System.out.println(Math.sqrt(ans));
    }
} 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();
        sc.nextLine();

        double t = (double) H*5 + (double) M/12;
        double sa = Math.abs(t - M);

        if (sa > 30) {
            sa = 60 - sa;
        }

        sa *= 6.0;

        double ans = Math.pow(A, 2) + Math.pow(B, 2) - 2.0 * A * B * Math.cos(Math.toRadians(sa));

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