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 t1 = (h + m / 60.0) / 12.0;
		double t2 = m / 60.0;
		// System.out.println(t1);
		// System.out.println(t2);
		double r = Math.toRadians(Math.abs(t2 - t1) * 360.0);
		// System.out.println(r);
		double ans = a * a + b * b - 2 * a * b * Math.cos(r);
		System.out.println(Math.sqrt(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 t1 = (h + m / 60.0) / 12.0;
		double t2 = m / 60.0;
		// System.out.println(t1);
		// System.out.println(t2);
		double r = Math.toRadians(Math.abs(t2 - t1) * 360.0);
		// System.out.println(r);
		double ans = a * a + b * b - 2 * a * b * Math.cos(r);
		System.out.println(Math.sqrt(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 t1 = (h + m / 60.0) / 12.0;
		double t2 = m / 60.0;
		// System.out.println(t1);
		// System.out.println(t2);
		double r = Math.toRadians(Math.abs(t2 - t1) * 360.0);
		// System.out.println(r);
		double ans = a * a + b * b - 2 * a * b * Math.cos(r);
		System.out.println(Math.sqrt(ans));
	} main {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int h = sc.nextInt();
		int m = sc.nextInt();
		double t1 = (h + m / 60.0) / 12.0;
		double t2 = m / 60.0;
		// System.out.println(t1);
		// System.out.println(t2);
		double r = Math.toRadians(Math.abs(t2 - t1) * 360.0);
		// System.out.println(r);
		double ans = a * a + b * b - 2 * a * b * Math.cos(r);
		System.out.println(Math.sqrt(ans));
	} 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 t1 = (h + m / 60.0) / 12.0; t1 (h + m / 60.0) / 12.0 (h + m / 60.0) h m / 60.0 m 60.0 12.0 double t2 = m / 60.0; t2 m / 60.0 m 60.0 double r = Math.toRadians(Math.abs(t2 - t1) * 360.0); r Math.toRadians(Math.abs(t2 - t1) * 360.0) Math.toRadians Math Math.abs(t2 - t1) * 360.0 Math.abs(t2 - t1) Math.abs Math t2 - t1 t2 t1 360.0 double ans = a * a + b * b - 2 * a * b * Math.cos(r); ans a * a + b * b - 2 * a * b * Math.cos(r) a * a + b * b a * a a a b * b b b 2 * a * b * Math.cos(r) b 2 * a * b * Math.cos(r) 2 a b Math.cos(r) Math.cos Math r 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 sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int h = sc.nextInt();
		int m = sc.nextInt();
		double t1 = (h + m / 60.0) / 12.0;
		double t2 = m / 60.0;
		// System.out.println(t1);
		// System.out.println(t2);
		double r = Math.toRadians(Math.abs(t2 - t1) * 360.0);
		// System.out.println(r);
		double ans = a * a + b * b - 2 * a * b * Math.cos(r);
		System.out.println(Math.sqrt(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 t1 = (h + m / 60.0) / 12.0;
		double t2 = m / 60.0;
		// System.out.println(t1);
		// System.out.println(t2);
		double r = Math.toRadians(Math.abs(t2 - t1) * 360.0);
		// System.out.println(r);
		double ans = a * a + b * b - 2 * a * b * Math.cos(r);
		System.out.println(Math.sqrt(ans));
	}
} Main
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 t1 = (h + m / 60.0) / 12.0;
		double t2 = m / 60.0;
		// System.out.println(t1);
		// System.out.println(t2);
		double r = Math.toRadians(Math.abs(t2 - t1) * 360.0);
		// System.out.println(r);
		double ans = a * a + b * b - 2 * a * b * Math.cos(r);
		System.out.println(Math.sqrt(ans));
	}
}
 
 
 
 
 
 
 
 
 
 
