import java.util.Scanner;
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();
	double angle = Math.abs(h*30+m*0.5-m*6);
	double result = Math.cos(Math.toRadians(angle));
	double x =a*a+b*b-2*a*b*result;
	double ans = Math.sqrt(x);
	System.out.println(ans);
	}
} import java.util.Scanner; Scanner 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();
	double angle = Math.abs(h*30+m*0.5-m*6);
	double result = Math.cos(Math.toRadians(angle));
	double x =a*a+b*b-2*a*b*result;
	double ans = Math.sqrt(x);
	System.out.println(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();
	double angle = Math.abs(h*30+m*0.5-m*6);
	double result = Math.cos(Math.toRadians(angle));
	double x =a*a+b*b-2*a*b*result;
	double ans = Math.sqrt(x);
	System.out.println(ans);
	} main {
	Scanner sc=new Scanner(System.in);
	int a=sc.nextInt();
	int b=sc.nextInt();
	int h=sc.nextInt();
	int m=sc.nextInt();
	double angle = Math.abs(h*30+m*0.5-m*6);
	double result = Math.cos(Math.toRadians(angle));
	double x =a*a+b*b-2*a*b*result;
	double ans = Math.sqrt(x);
	System.out.println(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 double angle = Math.abs(h*30+m*0.5-m*6); angle 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 result = Math.cos(Math.toRadians(angle)); result Math.cos(Math.toRadians(angle)) Math.cos Math Math.toRadians(angle) Math.toRadians Math angle double x =a*a+b*b-2*a*b*result; x a*a+b*b-2*a*b*result a*a+b*b a*a a a b*b b b 2*a*b*result b 2*a*b*result 2 a b result double ans = Math.sqrt(x); ans Math.sqrt(x) Math.sqrt Math x System.out.println(ans) System.out.println System.out System System.out 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();
	double angle = Math.abs(h*30+m*0.5-m*6);
	double result = Math.cos(Math.toRadians(angle));
	double x =a*a+b*b-2*a*b*result;
	double ans = Math.sqrt(x);
	System.out.println(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();
	double angle = Math.abs(h*30+m*0.5-m*6);
	double result = Math.cos(Math.toRadians(angle));
	double x =a*a+b*b-2*a*b*result;
	double ans = Math.sqrt(x);
	System.out.println(ans);
	}
} Main
import java.util.Scanner;
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();
	double angle = Math.abs(h*30+m*0.5-m*6);
	double result = Math.cos(Math.toRadians(angle));
	double x =a*a+b*b-2*a*b*result;
	double ans = Math.sqrt(x);
	System.out.println(ans);
	}
}