import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int h = scan.nextInt();
		int m = scan.nextInt();

		double lon = h * 30 + m * 0.5;
		double sho = m * 6 ;
		
		if(lon == 0) {
			lon = 360;
		}
		
		if(sho == 0) {
			sho = 360;
		}
		
		double big = 0;
		double small = 0;
		
		double answer = 0;
		
		if(lon > sho) {
			big = lon;
			small = sho;
		}else if(lon < sho) {
			big = sho;
			small = lon;
		}else if(lon == sho) {
			answer  = 0;
		}
		
		if((big - small) == 180) {
			answer = a + b;
		}
		
		
		double deg = big - small;
		if(deg > 180) {
			deg = 360 - deg;
		}
		
		if(deg > 180) {
			deg = 180 - (deg - 180);
		}
		
		double rad = Math.toRadians(deg);
		double cos = Math.cos(rad);
		answer = Math.sqrt(a*a + b*b - 2 * a * b * cos);
		
		if( deg == 90) {
			answer = Math.sqrt(a*a + b*b);
		}
		
		System.out.println(answer);
		
		
}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int h = scan.nextInt();
		int m = scan.nextInt();

		double lon = h * 30 + m * 0.5;
		double sho = m * 6 ;
		
		if(lon == 0) {
			lon = 360;
		}
		
		if(sho == 0) {
			sho = 360;
		}
		
		double big = 0;
		double small = 0;
		
		double answer = 0;
		
		if(lon > sho) {
			big = lon;
			small = sho;
		}else if(lon < sho) {
			big = sho;
			small = lon;
		}else if(lon == sho) {
			answer  = 0;
		}
		
		if((big - small) == 180) {
			answer = a + b;
		}
		
		
		double deg = big - small;
		if(deg > 180) {
			deg = 360 - deg;
		}
		
		if(deg > 180) {
			deg = 180 - (deg - 180);
		}
		
		double rad = Math.toRadians(deg);
		double cos = Math.cos(rad);
		answer = Math.sqrt(a*a + b*b - 2 * a * b * cos);
		
		if( deg == 90) {
			answer = Math.sqrt(a*a + b*b);
		}
		
		System.out.println(answer);
		
		
}
} Main public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int h = scan.nextInt();
		int m = scan.nextInt();

		double lon = h * 30 + m * 0.5;
		double sho = m * 6 ;
		
		if(lon == 0) {
			lon = 360;
		}
		
		if(sho == 0) {
			sho = 360;
		}
		
		double big = 0;
		double small = 0;
		
		double answer = 0;
		
		if(lon > sho) {
			big = lon;
			small = sho;
		}else if(lon < sho) {
			big = sho;
			small = lon;
		}else if(lon == sho) {
			answer  = 0;
		}
		
		if((big - small) == 180) {
			answer = a + b;
		}
		
		
		double deg = big - small;
		if(deg > 180) {
			deg = 360 - deg;
		}
		
		if(deg > 180) {
			deg = 180 - (deg - 180);
		}
		
		double rad = Math.toRadians(deg);
		double cos = Math.cos(rad);
		answer = Math.sqrt(a*a + b*b - 2 * a * b * cos);
		
		if( deg == 90) {
			answer = Math.sqrt(a*a + b*b);
		}
		
		System.out.println(answer);
		
		
} main {
		// TODO 自動生成されたメソッド・スタブ
		
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int h = scan.nextInt();
		int m = scan.nextInt();

		double lon = h * 30 + m * 0.5;
		double sho = m * 6 ;
		
		if(lon == 0) {
			lon = 360;
		}
		
		if(sho == 0) {
			sho = 360;
		}
		
		double big = 0;
		double small = 0;
		
		double answer = 0;
		
		if(lon > sho) {
			big = lon;
			small = sho;
		}else if(lon < sho) {
			big = sho;
			small = lon;
		}else if(lon == sho) {
			answer  = 0;
		}
		
		if((big - small) == 180) {
			answer = a + b;
		}
		
		
		double deg = big - small;
		if(deg > 180) {
			deg = 360 - deg;
		}
		
		if(deg > 180) {
			deg = 180 - (deg - 180);
		}
		
		double rad = Math.toRadians(deg);
		double cos = Math.cos(rad);
		answer = Math.sqrt(a*a + b*b - 2 * a * b * cos);
		
		if( deg == 90) {
			answer = Math.sqrt(a*a + b*b);
		}
		
		System.out.println(answer);
		
		
} 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 lon = h * 30 + m * 0.5; lon h * 30 + m * 0.5 h * 30 h 30 m * 0.5 m 0.5 double sho = m * 6 ; sho m * 6 m 6 if(lon == 0) {
			lon = 360;
		} lon == 0 lon 0 {
			lon = 360;
		} lon = 360 lon 360 if(sho == 0) {
			sho = 360;
		} sho == 0 sho 0 {
			sho = 360;
		} sho = 360 sho 360 double big = 0; big 0 double small = 0; small 0 double answer = 0; answer 0 if(lon > sho) {
			big = lon;
			small = sho;
		}else if(lon < sho) {
			big = sho;
			small = lon;
		}else if(lon == sho) {
			answer  = 0;
		} lon > sho lon sho {
			big = lon;
			small = sho;
		} big = lon big lon small = sho small sho if(lon < sho) {
			big = sho;
			small = lon;
		}else if(lon == sho) {
			answer  = 0;
		} lon < sho lon sho {
			big = sho;
			small = lon;
		} big = sho big sho small = lon small lon if(lon == sho) {
			answer  = 0;
		} lon == sho lon sho {
			answer  = 0;
		} answer  = 0 answer 0 if((big - small) == 180) {
			answer = a + b;
		} (big - small) == 180 (big - small) big small 180 {
			answer = a + b;
		} answer = a + b answer a + b a b double deg = big - small; deg big - small big small if(deg > 180) {
			deg = 360 - deg;
		} deg > 180 deg 180 {
			deg = 360 - deg;
		} deg = 360 - deg deg 360 - deg 360 deg if(deg > 180) {
			deg = 180 - (deg - 180);
		} deg > 180 deg 180 {
			deg = 180 - (deg - 180);
		} deg = 180 - (deg - 180) deg 180 - (deg - 180) 180 (deg - 180) deg 180 double rad = Math.toRadians(deg); rad Math.toRadians(deg) Math.toRadians Math deg double cos = Math.cos(rad); cos Math.cos(rad) Math.cos Math rad answer = Math.sqrt(a*a + b*b - 2 * a * b * cos) answer Math.sqrt(a*a + b*b - 2 * a * b * cos) Math.sqrt Math 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 if( deg == 90) {
			answer = Math.sqrt(a*a + b*b);
		} deg == 90 deg 90 {
			answer = Math.sqrt(a*a + b*b);
		} answer = Math.sqrt(a*a + b*b) answer Math.sqrt(a*a + b*b) Math.sqrt Math a*a + b*b a*a a a b*b b b System.out.println(answer) System.out.println System.out System System.out answer String[] args args public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int h = scan.nextInt();
		int m = scan.nextInt();

		double lon = h * 30 + m * 0.5;
		double sho = m * 6 ;
		
		if(lon == 0) {
			lon = 360;
		}
		
		if(sho == 0) {
			sho = 360;
		}
		
		double big = 0;
		double small = 0;
		
		double answer = 0;
		
		if(lon > sho) {
			big = lon;
			small = sho;
		}else if(lon < sho) {
			big = sho;
			small = lon;
		}else if(lon == sho) {
			answer  = 0;
		}
		
		if((big - small) == 180) {
			answer = a + b;
		}
		
		
		double deg = big - small;
		if(deg > 180) {
			deg = 360 - deg;
		}
		
		if(deg > 180) {
			deg = 180 - (deg - 180);
		}
		
		double rad = Math.toRadians(deg);
		double cos = Math.cos(rad);
		answer = Math.sqrt(a*a + b*b - 2 * a * b * cos);
		
		if( deg == 90) {
			answer = Math.sqrt(a*a + b*b);
		}
		
		System.out.println(answer);
		
		
}
} public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int h = scan.nextInt();
		int m = scan.nextInt();

		double lon = h * 30 + m * 0.5;
		double sho = m * 6 ;
		
		if(lon == 0) {
			lon = 360;
		}
		
		if(sho == 0) {
			sho = 360;
		}
		
		double big = 0;
		double small = 0;
		
		double answer = 0;
		
		if(lon > sho) {
			big = lon;
			small = sho;
		}else if(lon < sho) {
			big = sho;
			small = lon;
		}else if(lon == sho) {
			answer  = 0;
		}
		
		if((big - small) == 180) {
			answer = a + b;
		}
		
		
		double deg = big - small;
		if(deg > 180) {
			deg = 360 - deg;
		}
		
		if(deg > 180) {
			deg = 180 - (deg - 180);
		}
		
		double rad = Math.toRadians(deg);
		double cos = Math.cos(rad);
		answer = Math.sqrt(a*a + b*b - 2 * a * b * cos);
		
		if( deg == 90) {
			answer = Math.sqrt(a*a + b*b);
		}
		
		System.out.println(answer);
		
		
}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int h = scan.nextInt();
		int m = scan.nextInt();

		double lon = h * 30 + m * 0.5;
		double sho = m * 6 ;
		
		if(lon == 0) {
			lon = 360;
		}
		
		if(sho == 0) {
			sho = 360;
		}
		
		double big = 0;
		double small = 0;
		
		double answer = 0;
		
		if(lon > sho) {
			big = lon;
			small = sho;
		}else if(lon < sho) {
			big = sho;
			small = lon;
		}else if(lon == sho) {
			answer  = 0;
		}
		
		if((big - small) == 180) {
			answer = a + b;
		}
		
		
		double deg = big - small;
		if(deg > 180) {
			deg = 360 - deg;
		}
		
		if(deg > 180) {
			deg = 180 - (deg - 180);
		}
		
		double rad = Math.toRadians(deg);
		double cos = Math.cos(rad);
		answer = Math.sqrt(a*a + b*b - 2 * a * b * cos);
		
		if( deg == 90) {
			answer = Math.sqrt(a*a + b*b);
		}
		
		System.out.println(answer);
		
		
}
}
