//package atcoder;
 
import 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 h = 360/12*H+0.5*M;
		double m = 6*M;
	
			double kaku = h-m;
			if(kaku>180) {
				kaku = 360-kaku;
			}
			mat(A,B,Math.abs(kaku));
		
		
		
		}
	
	public static void mat(double A,double B,double shita){
		//System.out.println(shita);
		double kakudo = Math.toRadians(shita);
		//System.out.println(kakudo);
		double ans = Math.pow(A, 2)+Math.pow(B, 2)-2*A*B*Math.cos(kakudo);
		double Ans = Math.sqrt(ans);
		System.out.println(Ans);
	}
} import java.util.*; util.* java 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 h = 360/12*H+0.5*M;
		double m = 6*M;
	
			double kaku = h-m;
			if(kaku>180) {
				kaku = 360-kaku;
			}
			mat(A,B,Math.abs(kaku));
		
		
		
		}
	
	public static void mat(double A,double B,double shita){
		//System.out.println(shita);
		double kakudo = Math.toRadians(shita);
		//System.out.println(kakudo);
		double ans = Math.pow(A, 2)+Math.pow(B, 2)-2*A*B*Math.cos(kakudo);
		double Ans = Math.sqrt(ans);
		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 h = 360/12*H+0.5*M;
		double m = 6*M;
	
			double kaku = h-m;
			if(kaku>180) {
				kaku = 360-kaku;
			}
			mat(A,B,Math.abs(kaku));
		
		
		
		} main {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int H = sc.nextInt();
		int M = sc.nextInt();
		
		double h = 360/12*H+0.5*M;
		double m = 6*M;
	
			double kaku = h-m;
			if(kaku>180) {
				kaku = 360-kaku;
			}
			mat(A,B,Math.abs(kaku));
		
		
		
		} 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 h = 360/12*H+0.5*M; h 360/12*H+0.5*M 360/12*H 360/12 360 12 H 0.5*M 0.5 M double m = 6*M; m 6*M 6 M double kaku = h-m; kaku h-m h m if(kaku>180) {
				kaku = 360-kaku;
			} kaku>180 kaku 180 {
				kaku = 360-kaku;
			} kaku = 360-kaku kaku 360-kaku 360 kaku mat(A,B,Math.abs(kaku)) mat A B Math.abs(kaku) Math.abs Math kaku String[] args args public static void mat(double A,double B,double shita){
		//System.out.println(shita);
		double kakudo = Math.toRadians(shita);
		//System.out.println(kakudo);
		double ans = Math.pow(A, 2)+Math.pow(B, 2)-2*A*B*Math.cos(kakudo);
		double Ans = Math.sqrt(ans);
		System.out.println(Ans);
	} mat {
		//System.out.println(shita);
		double kakudo = Math.toRadians(shita);
		//System.out.println(kakudo);
		double ans = Math.pow(A, 2)+Math.pow(B, 2)-2*A*B*Math.cos(kakudo);
		double Ans = Math.sqrt(ans);
		System.out.println(Ans);
	} double kakudo = Math.toRadians(shita); kakudo Math.toRadians(shita) Math.toRadians Math shita double ans = Math.pow(A, 2)+Math.pow(B, 2)-2*A*B*Math.cos(kakudo); ans Math.pow(A, 2)+Math.pow(B, 2)-2*A*B*Math.cos(kakudo) Math.pow(A, 2)+Math.pow(B, 2) Math.pow(A, 2) Math.pow Math A 2 Math.pow(B, 2) Math.pow Math B 2 2*A*B*Math.cos(kakudo) B 2*A*B*Math.cos(kakudo) 2 A B Math.cos(kakudo) Math.cos Math kakudo double Ans = Math.sqrt(ans); Ans Math.sqrt(ans) Math.sqrt Math ans System.out.println(Ans) System.out.println System.out System System.out Ans double A A double B B double shita shita 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 h = 360/12*H+0.5*M;
		double m = 6*M;
	
			double kaku = h-m;
			if(kaku>180) {
				kaku = 360-kaku;
			}
			mat(A,B,Math.abs(kaku));
		
		
		
		}
	
	public static void mat(double A,double B,double shita){
		//System.out.println(shita);
		double kakudo = Math.toRadians(shita);
		//System.out.println(kakudo);
		double ans = Math.pow(A, 2)+Math.pow(B, 2)-2*A*B*Math.cos(kakudo);
		double Ans = Math.sqrt(ans);
		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 h = 360/12*H+0.5*M;
		double m = 6*M;
	
			double kaku = h-m;
			if(kaku>180) {
				kaku = 360-kaku;
			}
			mat(A,B,Math.abs(kaku));
		
		
		
		}
	
	public static void mat(double A,double B,double shita){
		//System.out.println(shita);
		double kakudo = Math.toRadians(shita);
		//System.out.println(kakudo);
		double ans = Math.pow(A, 2)+Math.pow(B, 2)-2*A*B*Math.cos(kakudo);
		double Ans = Math.sqrt(ans);
		System.out.println(Ans);
	}
} Main
//package atcoder;
 
import 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 h = 360/12*H+0.5*M;
		double m = 6*M;
	
			double kaku = h-m;
			if(kaku>180) {
				kaku = 360-kaku;
			}
			mat(A,B,Math.abs(kaku));
		
		
		
		}
	
	public static void mat(double A,double B,double shita){
		//System.out.println(shita);
		double kakudo = Math.toRadians(shita);
		//System.out.println(kakudo);
		double ans = Math.pow(A, 2)+Math.pow(B, 2)-2*A*B*Math.cos(kakudo);
		double Ans = Math.sqrt(ans);
		System.out.println(Ans);
	}
}
