import java.util.*;
 
public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		double A = in.nextDouble();
		double B = in.nextDouble();
		double ho = in.nextDouble();
		double mi = in.nextDouble();
		
		double rad = 60/mi;
		double radMi = 360/rad;
		double radiHo = (ho*30) + (30/rad);
		
		double radian = 0;
		if(radiHo > radMi){radian = radiHo - radMi;}
		else{radian = radMi - radiHo;}
		
		double result = (A*A) + (B*B) - 2*A*B* Math.cos(Math.toRadians(radian));
		double ans = Math.sqrt(result);
		System.out.println(ans);
		
		
      
	}
} import java.util.*; util.* java public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		double A = in.nextDouble();
		double B = in.nextDouble();
		double ho = in.nextDouble();
		double mi = in.nextDouble();
		
		double rad = 60/mi;
		double radMi = 360/rad;
		double radiHo = (ho*30) + (30/rad);
		
		double radian = 0;
		if(radiHo > radMi){radian = radiHo - radMi;}
		else{radian = radMi - radiHo;}
		
		double result = (A*A) + (B*B) - 2*A*B* Math.cos(Math.toRadians(radian));
		double ans = Math.sqrt(result);
		System.out.println(ans);
		
		
      
	}
} Main public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		double A = in.nextDouble();
		double B = in.nextDouble();
		double ho = in.nextDouble();
		double mi = in.nextDouble();
		
		double rad = 60/mi;
		double radMi = 360/rad;
		double radiHo = (ho*30) + (30/rad);
		
		double radian = 0;
		if(radiHo > radMi){radian = radiHo - radMi;}
		else{radian = radMi - radiHo;}
		
		double result = (A*A) + (B*B) - 2*A*B* Math.cos(Math.toRadians(radian));
		double ans = Math.sqrt(result);
		System.out.println(ans);
		
		
      
	} main {
		Scanner in = new Scanner(System.in);
		
		double A = in.nextDouble();
		double B = in.nextDouble();
		double ho = in.nextDouble();
		double mi = in.nextDouble();
		
		double rad = 60/mi;
		double radMi = 360/rad;
		double radiHo = (ho*30) + (30/rad);
		
		double radian = 0;
		if(radiHo > radMi){radian = radiHo - radMi;}
		else{radian = radMi - radiHo;}
		
		double result = (A*A) + (B*B) - 2*A*B* Math.cos(Math.toRadians(radian));
		double ans = Math.sqrt(result);
		System.out.println(ans);
		
		
      
	} Scanner in = new Scanner(System.in); in new Scanner(System.in) double A = in.nextDouble(); A in.nextDouble() in.nextDouble in double B = in.nextDouble(); B in.nextDouble() in.nextDouble in double ho = in.nextDouble(); ho in.nextDouble() in.nextDouble in double mi = in.nextDouble(); mi in.nextDouble() in.nextDouble in double rad = 60/mi; rad 60/mi 60 mi double radMi = 360/rad; radMi 360/rad 360 rad double radiHo = (ho*30) + (30/rad); radiHo (ho*30) + (30/rad) (ho*30) ho 30 (30/rad) 30 rad double radian = 0; radian 0 if(radiHo > radMi){radian = radiHo - radMi;}
		else{radian = radMi - radiHo;} radiHo > radMi radiHo radMi {radian = radiHo - radMi;} radian = radiHo - radMi radian radiHo - radMi radiHo radMi {radian = radMi - radiHo;} radian = radMi - radiHo radian radMi - radiHo radMi radiHo double result = (A*A) + (B*B) - 2*A*B* Math.cos(Math.toRadians(radian)); result (A*A) + (B*B) - 2*A*B* Math.cos(Math.toRadians(radian)) (A*A) + (B*B) (A*A) A A (B*B) B B 2*A*B* Math.cos(Math.toRadians(radian)) B 2*A*B* Math.cos(Math.toRadians(radian)) 2 A B Math.cos(Math.toRadians(radian)) Math.cos Math Math.toRadians(radian) Math.toRadians Math radian double ans = Math.sqrt(result); ans Math.sqrt(result) Math.sqrt Math result 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 in = new Scanner(System.in);
		
		double A = in.nextDouble();
		double B = in.nextDouble();
		double ho = in.nextDouble();
		double mi = in.nextDouble();
		
		double rad = 60/mi;
		double radMi = 360/rad;
		double radiHo = (ho*30) + (30/rad);
		
		double radian = 0;
		if(radiHo > radMi){radian = radiHo - radMi;}
		else{radian = radMi - radiHo;}
		
		double result = (A*A) + (B*B) - 2*A*B* Math.cos(Math.toRadians(radian));
		double ans = Math.sqrt(result);
		System.out.println(ans);
		
		
      
	}
} public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		double A = in.nextDouble();
		double B = in.nextDouble();
		double ho = in.nextDouble();
		double mi = in.nextDouble();
		
		double rad = 60/mi;
		double radMi = 360/rad;
		double radiHo = (ho*30) + (30/rad);
		
		double radian = 0;
		if(radiHo > radMi){radian = radiHo - radMi;}
		else{radian = radMi - radiHo;}
		
		double result = (A*A) + (B*B) - 2*A*B* Math.cos(Math.toRadians(radian));
		double ans = Math.sqrt(result);
		System.out.println(ans);
		
		
      
	}
} Main
import java.util.*;
 
public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		double A = in.nextDouble();
		double B = in.nextDouble();
		double ho = in.nextDouble();
		double mi = in.nextDouble();
		
		double rad = 60/mi;
		double radMi = 360/rad;
		double radiHo = (ho*30) + (30/rad);
		
		double radian = 0;
		if(radiHo > radMi){radian = radiHo - radMi;}
		else{radian = radMi - radiHo;}
		
		double result = (A*A) + (B*B) - 2*A*B* Math.cos(Math.toRadians(radian));
		double ans = Math.sqrt(result);
		System.out.println(ans);
		
		
      
	}
}