import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        double a=sc.nextDouble();
        double b=sc.nextDouble();
  		double h=sc.nextDouble();
  		double m=sc.nextDouble();
		double mr=Math.toRadians(m*6);
  		double hr=Math.toRadians(30*h+m*0.5);
        double sar=Math.abs(mr-hr);
  		double ans=Math.sqrt(a*a+b*b-2*a*b*Math.cos(sar));

    	System.out.println(ans);
    }
} import java.util.*; util.* java class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        double a=sc.nextDouble();
        double b=sc.nextDouble();
  		double h=sc.nextDouble();
  		double m=sc.nextDouble();
		double mr=Math.toRadians(m*6);
  		double hr=Math.toRadians(30*h+m*0.5);
        double sar=Math.abs(mr-hr);
  		double ans=Math.sqrt(a*a+b*b-2*a*b*Math.cos(sar));

    	System.out.println(ans);
    }
} Main public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        double a=sc.nextDouble();
        double b=sc.nextDouble();
  		double h=sc.nextDouble();
  		double m=sc.nextDouble();
		double mr=Math.toRadians(m*6);
  		double hr=Math.toRadians(30*h+m*0.5);
        double sar=Math.abs(mr-hr);
  		double ans=Math.sqrt(a*a+b*b-2*a*b*Math.cos(sar));

    	System.out.println(ans);
    } main {
	Scanner sc=new Scanner(System.in);
        double a=sc.nextDouble();
        double b=sc.nextDouble();
  		double h=sc.nextDouble();
  		double m=sc.nextDouble();
		double mr=Math.toRadians(m*6);
  		double hr=Math.toRadians(30*h+m*0.5);
        double sar=Math.abs(mr-hr);
  		double ans=Math.sqrt(a*a+b*b-2*a*b*Math.cos(sar));

    	System.out.println(ans);
    } Scanner sc=new Scanner(System.in); sc new Scanner(System.in) double a=sc.nextDouble(); a sc.nextDouble() sc.nextDouble sc double b=sc.nextDouble(); b sc.nextDouble() sc.nextDouble sc double h=sc.nextDouble(); h sc.nextDouble() sc.nextDouble sc double m=sc.nextDouble(); m sc.nextDouble() sc.nextDouble sc double mr=Math.toRadians(m*6); mr Math.toRadians(m*6) Math.toRadians Math m*6 m 6 double hr=Math.toRadians(30*h+m*0.5); hr Math.toRadians(30*h+m*0.5) Math.toRadians Math 30*h+m*0.5 30*h 30 h m*0.5 m 0.5 double sar=Math.abs(mr-hr); sar Math.abs(mr-hr) Math.abs Math mr-hr mr hr double ans=Math.sqrt(a*a+b*b-2*a*b*Math.cos(sar)); ans Math.sqrt(a*a+b*b-2*a*b*Math.cos(sar)) Math.sqrt Math a*a+b*b-2*a*b*Math.cos(sar) a*a+b*b a*a a a b*b b b 2*a*b*Math.cos(sar) b 2*a*b*Math.cos(sar) 2 a b Math.cos(sar) Math.cos Math sar System.out.println(ans) System.out.println System.out System System.out ans String[] args args
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        double a=sc.nextDouble();
        double b=sc.nextDouble();
  		double h=sc.nextDouble();
  		double m=sc.nextDouble();
		double mr=Math.toRadians(m*6);
  		double hr=Math.toRadians(30*h+m*0.5);
        double sar=Math.abs(mr-hr);
  		double ans=Math.sqrt(a*a+b*b-2*a*b*Math.cos(sar));

    	System.out.println(ans);
    }
}