import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		int h = in.nextInt();
		int m = in.nextInt();
		double h_ang = (h*30) + (m*0.5);
		double m_ang = m*6;
		double tmp = 0;
		if(h>m){
			tmp = h_ang - m_ang;
		}else{
			tmp = m_ang - h_ang;
		}
		if(tmp>180){
			tmp-=360;
		}
		double cos = Math.cos(Math.toRadians(tmp));
		double result = (a*a) + (b*b) - (2*a*b*cos);
		System.out.println(Math.sqrt(result));
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		int h = in.nextInt();
		int m = in.nextInt();
		double h_ang = (h*30) + (m*0.5);
		double m_ang = m*6;
		double tmp = 0;
		if(h>m){
			tmp = h_ang - m_ang;
		}else{
			tmp = m_ang - h_ang;
		}
		if(tmp>180){
			tmp-=360;
		}
		double cos = Math.cos(Math.toRadians(tmp));
		double result = (a*a) + (b*b) - (2*a*b*cos);
		System.out.println(Math.sqrt(result));
	}
} Main public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		int h = in.nextInt();
		int m = in.nextInt();
		double h_ang = (h*30) + (m*0.5);
		double m_ang = m*6;
		double tmp = 0;
		if(h>m){
			tmp = h_ang - m_ang;
		}else{
			tmp = m_ang - h_ang;
		}
		if(tmp>180){
			tmp-=360;
		}
		double cos = Math.cos(Math.toRadians(tmp));
		double result = (a*a) + (b*b) - (2*a*b*cos);
		System.out.println(Math.sqrt(result));
	} main {
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		int h = in.nextInt();
		int m = in.nextInt();
		double h_ang = (h*30) + (m*0.5);
		double m_ang = m*6;
		double tmp = 0;
		if(h>m){
			tmp = h_ang - m_ang;
		}else{
			tmp = m_ang - h_ang;
		}
		if(tmp>180){
			tmp-=360;
		}
		double cos = Math.cos(Math.toRadians(tmp));
		double result = (a*a) + (b*b) - (2*a*b*cos);
		System.out.println(Math.sqrt(result));
	} Scanner in = new Scanner(System.in); in new Scanner(System.in) int a = in.nextInt(); a in.nextInt() in.nextInt in int b = in.nextInt(); b in.nextInt() in.nextInt in int h = in.nextInt(); h in.nextInt() in.nextInt in int m = in.nextInt(); m in.nextInt() in.nextInt in double h_ang = (h*30) + (m*0.5); h_ang (h*30) + (m*0.5) (h*30) h 30 (m*0.5) m 0.5 double m_ang = m*6; m_ang m*6 m 6 double tmp = 0; tmp 0 if(h>m){
			tmp = h_ang - m_ang;
		}else{
			tmp = m_ang - h_ang;
		} h>m h m {
			tmp = h_ang - m_ang;
		} tmp = h_ang - m_ang tmp h_ang - m_ang h_ang m_ang {
			tmp = m_ang - h_ang;
		} tmp = m_ang - h_ang tmp m_ang - h_ang m_ang h_ang if(tmp>180){
			tmp-=360;
		} tmp>180 tmp 180 {
			tmp-=360;
		} tmp-=360 tmp 360 double cos = Math.cos(Math.toRadians(tmp)); cos Math.cos(Math.toRadians(tmp)) Math.cos Math Math.toRadians(tmp) Math.toRadians Math tmp double result = (a*a) + (b*b) - (2*a*b*cos); result (a*a) + (b*b) - (2*a*b*cos) (a*a) + (b*b) (a*a) a a (b*b) b b (2*a*b*cos) b 2*a*b*cos 2 a b cos System.out.println(Math.sqrt(result)) System.out.println System.out System System.out Math.sqrt(result) Math.sqrt Math result String[] args args public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		int h = in.nextInt();
		int m = in.nextInt();
		double h_ang = (h*30) + (m*0.5);
		double m_ang = m*6;
		double tmp = 0;
		if(h>m){
			tmp = h_ang - m_ang;
		}else{
			tmp = m_ang - h_ang;
		}
		if(tmp>180){
			tmp-=360;
		}
		double cos = Math.cos(Math.toRadians(tmp));
		double result = (a*a) + (b*b) - (2*a*b*cos);
		System.out.println(Math.sqrt(result));
	}
} public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		int h = in.nextInt();
		int m = in.nextInt();
		double h_ang = (h*30) + (m*0.5);
		double m_ang = m*6;
		double tmp = 0;
		if(h>m){
			tmp = h_ang - m_ang;
		}else{
			tmp = m_ang - h_ang;
		}
		if(tmp>180){
			tmp-=360;
		}
		double cos = Math.cos(Math.toRadians(tmp));
		double result = (a*a) + (b*b) - (2*a*b*cos);
		System.out.println(Math.sqrt(result));
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		int h = in.nextInt();
		int m = in.nextInt();
		double h_ang = (h*30) + (m*0.5);
		double m_ang = m*6;
		double tmp = 0;
		if(h>m){
			tmp = h_ang - m_ang;
		}else{
			tmp = m_ang - h_ang;
		}
		if(tmp>180){
			tmp-=360;
		}
		double cos = Math.cos(Math.toRadians(tmp));
		double result = (a*a) + (b*b) - (2*a*b*cos);
		System.out.println(Math.sqrt(result));
	}
}
