import java.util.*;
 
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        double a, b, h, m;
        a = sc.nextDouble();
        b = sc.nextDouble();
        h = sc.nextDouble();
        m = sc.nextDouble();
        double angle = Math.min(Math.abs(h * 30 + m * 0.5 - m * 6), 360 - Math.abs(h * 30 + m * 0.5 - m * 6));
        double pi = angle / 180 * Math.PI;
        System.out.println(Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(pi)));
    }
} import java.util.*; util.* java public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        double a, b, h, m;
        a = sc.nextDouble();
        b = sc.nextDouble();
        h = sc.nextDouble();
        m = sc.nextDouble();
        double angle = Math.min(Math.abs(h * 30 + m * 0.5 - m * 6), 360 - Math.abs(h * 30 + m * 0.5 - m * 6));
        double pi = angle / 180 * Math.PI;
        System.out.println(Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(pi)));
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        double a, b, h, m;
        a = sc.nextDouble();
        b = sc.nextDouble();
        h = sc.nextDouble();
        m = sc.nextDouble();
        double angle = Math.min(Math.abs(h * 30 + m * 0.5 - m * 6), 360 - Math.abs(h * 30 + m * 0.5 - m * 6));
        double pi = angle / 180 * Math.PI;
        System.out.println(Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(pi)));
    } main {
        Scanner sc = new Scanner(System.in);
        double a, b, h, m;
        a = sc.nextDouble();
        b = sc.nextDouble();
        h = sc.nextDouble();
        m = sc.nextDouble();
        double angle = Math.min(Math.abs(h * 30 + m * 0.5 - m * 6), 360 - Math.abs(h * 30 + m * 0.5 - m * 6));
        double pi = angle / 180 * Math.PI;
        System.out.println(Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(pi)));
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) double a a b b h h m; m a = sc.nextDouble() a sc.nextDouble() sc.nextDouble sc b = sc.nextDouble() b sc.nextDouble() sc.nextDouble sc h = sc.nextDouble() h sc.nextDouble() sc.nextDouble sc m = sc.nextDouble() m sc.nextDouble() sc.nextDouble sc double angle = Math.min(Math.abs(h * 30 + m * 0.5 - m * 6), 360 - Math.abs(h * 30 + m * 0.5 - m * 6)); angle Math.min(Math.abs(h * 30 + m * 0.5 - m * 6), 360 - Math.abs(h * 30 + m * 0.5 - m * 6)) Math.min Math Math.abs(h * 30 + m * 0.5 - m * 6) Math.abs Math h * 30 + m * 0.5 - m * 6 h * 30 + m * 0.5 h * 30 h 30 m * 0.5 m 0.5 m * 6 m 6 360 - Math.abs(h * 30 + m * 0.5 - m * 6) 360 Math.abs(h * 30 + m * 0.5 - m * 6) Math.abs Math h * 30 + m * 0.5 - m * 6 h * 30 + m * 0.5 h * 30 h 30 m * 0.5 m 0.5 m * 6 m 6 double pi = angle / 180 * Math.PI; pi angle / 180 * Math.PI angle / 180 angle 180 Math.PI Math Math.PI System.out.println(Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(pi))) System.out.println System.out System System.out Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(pi)) Math.sqrt Math a * a + b * b - 2 * a * b * Math.cos(pi) a * a + b * b a * a a a b * b b b 2 * a * b * Math.cos(pi) b 2 * a * b * Math.cos(pi) 2 a b Math.cos(pi) Math.cos Math pi String[] args args public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        double a, b, h, m;
        a = sc.nextDouble();
        b = sc.nextDouble();
        h = sc.nextDouble();
        m = sc.nextDouble();
        double angle = Math.min(Math.abs(h * 30 + m * 0.5 - m * 6), 360 - Math.abs(h * 30 + m * 0.5 - m * 6));
        double pi = angle / 180 * Math.PI;
        System.out.println(Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(pi)));
    }
} public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        double a, b, h, m;
        a = sc.nextDouble();
        b = sc.nextDouble();
        h = sc.nextDouble();
        m = sc.nextDouble();
        double angle = Math.min(Math.abs(h * 30 + m * 0.5 - m * 6), 360 - Math.abs(h * 30 + m * 0.5 - m * 6));
        double pi = angle / 180 * Math.PI;
        System.out.println(Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(pi)));
    }
} Main
import java.util.*;
 
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        double a, b, h, m;
        a = sc.nextDouble();
        b = sc.nextDouble();
        h = sc.nextDouble();
        m = sc.nextDouble();
        double angle = Math.min(Math.abs(h * 30 + m * 0.5 - m * 6), 360 - Math.abs(h * 30 + m * 0.5 - m * 6));
        double pi = angle / 180 * Math.PI;
        System.out.println(Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(pi)));
    }
}