import java.util.*;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int a = scan.nextInt();
		int b = scan.nextInt();
		int h = scan.nextInt();
		int m = scan.nextInt();
		double kaku = 0;
		
		double h_kaku = h*30;
		if(m!=0) {
			h_kaku += m*0.5;
		}
		double m_kaku = m*6;
		
		kaku = Math.min(h_kaku-m_kaku, 360-(h_kaku-m_kaku));
		double ans = 0;
		
		
		if(kaku!=90) {
			ans = Math.pow(a, 2)+Math.pow(b, 2)-2*a*b*Math.cos(kaku*(Math.PI/180));
		}else {
			ans = Math.pow(a, 2)+Math.pow(b, 2)-2*a*b*0;
		}
		
		System.out.println(Math.sqrt(ans));
		
		
		
		
	}	
	
	
	//�ŏ�����
	/*
	static int gcd (int a, int b) {
		int temp;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return b;
	}
	*/
	
	//����ւ�
	/*
	static int swap (int a, int b) {
		int swap_arr[] = new int[2];
		
		swap[0] = b;
		swap[1] = a;
		
		return swap_arr;
	}
	*/
	
}
 import java.util.*; util.* java import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int a = scan.nextInt();
		int b = scan.nextInt();
		int h = scan.nextInt();
		int m = scan.nextInt();
		double kaku = 0;
		
		double h_kaku = h*30;
		if(m!=0) {
			h_kaku += m*0.5;
		}
		double m_kaku = m*6;
		
		kaku = Math.min(h_kaku-m_kaku, 360-(h_kaku-m_kaku));
		double ans = 0;
		
		
		if(kaku!=90) {
			ans = Math.pow(a, 2)+Math.pow(b, 2)-2*a*b*Math.cos(kaku*(Math.PI/180));
		}else {
			ans = Math.pow(a, 2)+Math.pow(b, 2)-2*a*b*0;
		}
		
		System.out.println(Math.sqrt(ans));
		
		
		
		
	}	
	
	
	//�ŏ�����
	/*
	static int gcd (int a, int b) {
		int temp;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return b;
	}
	*/
	
	//����ւ�
	/*
	static int swap (int a, int b) {
		int swap_arr[] = new int[2];
		
		swap[0] = b;
		swap[1] = a;
		
		return swap_arr;
	}
	*/
	
} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int a = scan.nextInt();
		int b = scan.nextInt();
		int h = scan.nextInt();
		int m = scan.nextInt();
		double kaku = 0;
		
		double h_kaku = h*30;
		if(m!=0) {
			h_kaku += m*0.5;
		}
		double m_kaku = m*6;
		
		kaku = Math.min(h_kaku-m_kaku, 360-(h_kaku-m_kaku));
		double ans = 0;
		
		
		if(kaku!=90) {
			ans = Math.pow(a, 2)+Math.pow(b, 2)-2*a*b*Math.cos(kaku*(Math.PI/180));
		}else {
			ans = Math.pow(a, 2)+Math.pow(b, 2)-2*a*b*0;
		}
		
		System.out.println(Math.sqrt(ans));
		
		
		
		
	} main {
		Scanner scan = new Scanner(System.in);
		
		int a = scan.nextInt();
		int b = scan.nextInt();
		int h = scan.nextInt();
		int m = scan.nextInt();
		double kaku = 0;
		
		double h_kaku = h*30;
		if(m!=0) {
			h_kaku += m*0.5;
		}
		double m_kaku = m*6;
		
		kaku = Math.min(h_kaku-m_kaku, 360-(h_kaku-m_kaku));
		double ans = 0;
		
		
		if(kaku!=90) {
			ans = Math.pow(a, 2)+Math.pow(b, 2)-2*a*b*Math.cos(kaku*(Math.PI/180));
		}else {
			ans = Math.pow(a, 2)+Math.pow(b, 2)-2*a*b*0;
		}
		
		System.out.println(Math.sqrt(ans));
		
		
		
		
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int a = scan.nextInt(); a scan.nextInt() scan.nextInt scan int b = scan.nextInt(); b scan.nextInt() scan.nextInt scan int h = scan.nextInt(); h scan.nextInt() scan.nextInt scan int m = scan.nextInt(); m scan.nextInt() scan.nextInt scan double kaku = 0; kaku 0 double h_kaku = h*30; h_kaku h*30 h 30 if(m!=0) {
			h_kaku += m*0.5;
		} m!=0 m 0 {
			h_kaku += m*0.5;
		} h_kaku += m*0.5 h_kaku m*0.5 m 0.5 double m_kaku = m*6; m_kaku m*6 m 6 kaku = Math.min(h_kaku-m_kaku, 360-(h_kaku-m_kaku)) kaku Math.min(h_kaku-m_kaku, 360-(h_kaku-m_kaku)) Math.min Math h_kaku-m_kaku h_kaku m_kaku 360-(h_kaku-m_kaku) 360 (h_kaku-m_kaku) h_kaku m_kaku double ans = 0; ans 0 if(kaku!=90) {
			ans = Math.pow(a, 2)+Math.pow(b, 2)-2*a*b*Math.cos(kaku*(Math.PI/180));
		}else {
			ans = Math.pow(a, 2)+Math.pow(b, 2)-2*a*b*0;
		} kaku!=90 kaku 90 {
			ans = Math.pow(a, 2)+Math.pow(b, 2)-2*a*b*Math.cos(kaku*(Math.PI/180));
		} ans = Math.pow(a, 2)+Math.pow(b, 2)-2*a*b*Math.cos(kaku*(Math.PI/180)) ans Math.pow(a, 2)+Math.pow(b, 2)-2*a*b*Math.cos(kaku*(Math.PI/180)) 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(kaku*(Math.PI/180)) b 2*a*b*Math.cos(kaku*(Math.PI/180)) 2 a b Math.cos(kaku*(Math.PI/180)) Math.cos Math kaku*(Math.PI/180) kaku (Math.PI/180) Math.PI Math Math.PI 180 {
			ans = Math.pow(a, 2)+Math.pow(b, 2)-2*a*b*0;
		} ans = Math.pow(a, 2)+Math.pow(b, 2)-2*a*b*0 ans Math.pow(a, 2)+Math.pow(b, 2)-2*a*b*0 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*0 b 2*a*b*0 2 a b 0 System.out.println(Math.sqrt(ans)) System.out.println System.out System System.out Math.sqrt(ans) Math.sqrt Math ans String[] args args public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int a = scan.nextInt();
		int b = scan.nextInt();
		int h = scan.nextInt();
		int m = scan.nextInt();
		double kaku = 0;
		
		double h_kaku = h*30;
		if(m!=0) {
			h_kaku += m*0.5;
		}
		double m_kaku = m*6;
		
		kaku = Math.min(h_kaku-m_kaku, 360-(h_kaku-m_kaku));
		double ans = 0;
		
		
		if(kaku!=90) {
			ans = Math.pow(a, 2)+Math.pow(b, 2)-2*a*b*Math.cos(kaku*(Math.PI/180));
		}else {
			ans = Math.pow(a, 2)+Math.pow(b, 2)-2*a*b*0;
		}
		
		System.out.println(Math.sqrt(ans));
		
		
		
		
	}	
	
	
	//�ŏ�����
	/*
	static int gcd (int a, int b) {
		int temp;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return b;
	}
	*/
	
	//����ւ�
	/*
	static int swap (int a, int b) {
		int swap_arr[] = new int[2];
		
		swap[0] = b;
		swap[1] = a;
		
		return swap_arr;
	}
	*/
	
} public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int a = scan.nextInt();
		int b = scan.nextInt();
		int h = scan.nextInt();
		int m = scan.nextInt();
		double kaku = 0;
		
		double h_kaku = h*30;
		if(m!=0) {
			h_kaku += m*0.5;
		}
		double m_kaku = m*6;
		
		kaku = Math.min(h_kaku-m_kaku, 360-(h_kaku-m_kaku));
		double ans = 0;
		
		
		if(kaku!=90) {
			ans = Math.pow(a, 2)+Math.pow(b, 2)-2*a*b*Math.cos(kaku*(Math.PI/180));
		}else {
			ans = Math.pow(a, 2)+Math.pow(b, 2)-2*a*b*0;
		}
		
		System.out.println(Math.sqrt(ans));
		
		
		
		
	}	
	
	
	//�ŏ�����
	/*
	static int gcd (int a, int b) {
		int temp;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return b;
	}
	*/
	
	//����ւ�
	/*
	static int swap (int a, int b) {
		int swap_arr[] = new int[2];
		
		swap[0] = b;
		swap[1] = a;
		
		return swap_arr;
	}
	*/
	
} Main
import java.util.*;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int a = scan.nextInt();
		int b = scan.nextInt();
		int h = scan.nextInt();
		int m = scan.nextInt();
		double kaku = 0;
		
		double h_kaku = h*30;
		if(m!=0) {
			h_kaku += m*0.5;
		}
		double m_kaku = m*6;
		
		kaku = Math.min(h_kaku-m_kaku, 360-(h_kaku-m_kaku));
		double ans = 0;
		
		
		if(kaku!=90) {
			ans = Math.pow(a, 2)+Math.pow(b, 2)-2*a*b*Math.cos(kaku*(Math.PI/180));
		}else {
			ans = Math.pow(a, 2)+Math.pow(b, 2)-2*a*b*0;
		}
		
		System.out.println(Math.sqrt(ans));
		
		
		
		
	}	
	
	
	//�ŏ�����
	/*
	static int gcd (int a, int b) {
		int temp;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return b;
	}
	*/
	
	//����ւ�
	/*
	static int swap (int a, int b) {
		int swap_arr[] = new int[2];
		
		swap[0] = b;
		swap[1] = a;
		
		return swap_arr;
	}
	*/
	
}

