import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int h = scan.nextInt();
        int m = scan.nextInt();
        double angle = h * 30 - m * 5.5;
        angle = Math.abs(angle > 180 ? 360 - angle : angle);
        System.out.println(Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(Math.toRadians(angle))));
        scan.close();
    }
} import java.util.*; util.* java public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int h = scan.nextInt();
        int m = scan.nextInt();
        double angle = h * 30 - m * 5.5;
        angle = Math.abs(angle > 180 ? 360 - angle : angle);
        System.out.println(Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(Math.toRadians(angle))));
        scan.close();
    }
} Main public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int h = scan.nextInt();
        int m = scan.nextInt();
        double angle = h * 30 - m * 5.5;
        angle = Math.abs(angle > 180 ? 360 - angle : angle);
        System.out.println(Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(Math.toRadians(angle))));
        scan.close();
    } main {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int h = scan.nextInt();
        int m = scan.nextInt();
        double angle = h * 30 - m * 5.5;
        angle = Math.abs(angle > 180 ? 360 - angle : angle);
        System.out.println(Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(Math.toRadians(angle))));
        scan.close();
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int a = scan.nextInt(); a scan.nextInt() scan.nextInt scan int b = scan.nextInt(); b scan.nextInt() scan.nextInt scan int h = scan.nextInt(); h scan.nextInt() scan.nextInt scan int m = scan.nextInt(); m scan.nextInt() scan.nextInt scan double angle = h * 30 - m * 5.5; angle h * 30 - m * 5.5 h * 30 h 30 m * 5.5 m 5.5 angle = Math.abs(angle > 180 ? 360 - angle : angle) angle Math.abs(angle > 180 ? 360 - angle : angle) Math.abs Math angle > 180 ? 360 - angle : angle angle > 180 angle 180 360 - angle 360 angle angle System.out.println(Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(Math.toRadians(angle)))) System.out.println System.out System System.out Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(Math.toRadians(angle))) Math.sqrt Math a * a + b * b - 2 * a * b * Math.cos(Math.toRadians(angle)) a * a + b * b a * a a a b * b b b 2 * a * b * Math.cos(Math.toRadians(angle)) b 2 * a * b * Math.cos(Math.toRadians(angle)) 2 a b Math.cos(Math.toRadians(angle)) Math.cos Math Math.toRadians(angle) Math.toRadians Math angle scan.close() scan.close scan String[] args args public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int h = scan.nextInt();
        int m = scan.nextInt();
        double angle = h * 30 - m * 5.5;
        angle = Math.abs(angle > 180 ? 360 - angle : angle);
        System.out.println(Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(Math.toRadians(angle))));
        scan.close();
    }
} public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int h = scan.nextInt();
        int m = scan.nextInt();
        double angle = h * 30 - m * 5.5;
        angle = Math.abs(angle > 180 ? 360 - angle : angle);
        System.out.println(Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(Math.toRadians(angle))));
        scan.close();
    }
} Main
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int h = scan.nextInt();
        int m = scan.nextInt();
        double angle = h * 30 - m * 5.5;
        angle = Math.abs(angle > 180 ? 360 - angle : angle);
        System.out.println(Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(Math.toRadians(angle))));
        scan.close();
    }
}