import java.util.Scanner;



public class Main {


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int h = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());

		double l = m * 6;
		double s = (h * 60 + m) * 0.5;
		double kakudo = s - l;
		double result = Math.cos(Math.toRadians(kakudo));
		double rsq = (a * a) + (b * b) - (2 * a * b * result);
		System.out.println(Math.sqrt(rsq));


	}
} import java.util.Scanner; Scanner java.util public class Main {


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int h = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());

		double l = m * 6;
		double s = (h * 60 + m) * 0.5;
		double kakudo = s - l;
		double result = Math.cos(Math.toRadians(kakudo));
		double rsq = (a * a) + (b * b) - (2 * a * b * result);
		System.out.println(Math.sqrt(rsq));


	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int h = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());

		double l = m * 6;
		double s = (h * 60 + m) * 0.5;
		double kakudo = s - l;
		double result = Math.cos(Math.toRadians(kakudo));
		double rsq = (a * a) + (b * b) - (2 * a * b * result);
		System.out.println(Math.sqrt(rsq));


	} main {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int h = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());

		double l = m * 6;
		double s = (h * 60 + m) * 0.5;
		double kakudo = s - l;
		double result = Math.cos(Math.toRadians(kakudo));
		double rsq = (a * a) + (b * b) - (2 * a * b * result);
		System.out.println(Math.sqrt(rsq));


	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int a = Integer.parseInt(sc.next()); a Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int b = Integer.parseInt(sc.next()); b Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int h = Integer.parseInt(sc.next()); h Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int m = Integer.parseInt(sc.next()); m Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc double l = m * 6; l m * 6 m 6 double s = (h * 60 + m) * 0.5; s (h * 60 + m) * 0.5 (h * 60 + m) h * 60 h 60 m 0.5 double kakudo = s - l; kakudo s - l s l double result = Math.cos(Math.toRadians(kakudo)); result Math.cos(Math.toRadians(kakudo)) Math.cos Math Math.toRadians(kakudo) Math.toRadians Math kakudo double rsq = (a * a) + (b * b) - (2 * a * b * result); rsq (a * a) + (b * b) - (2 * a * b * result) (a * a) + (b * b) (a * a) a a (b * b) b b (2 * a * b * result) b 2 * a * b * result 2 a b result System.out.println(Math.sqrt(rsq)) System.out.println System.out System System.out Math.sqrt(rsq) Math.sqrt Math rsq String[] args args public class Main {


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int h = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());

		double l = m * 6;
		double s = (h * 60 + m) * 0.5;
		double kakudo = s - l;
		double result = Math.cos(Math.toRadians(kakudo));
		double rsq = (a * a) + (b * b) - (2 * a * b * result);
		System.out.println(Math.sqrt(rsq));


	}
} public class Main {


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int h = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());

		double l = m * 6;
		double s = (h * 60 + m) * 0.5;
		double kakudo = s - l;
		double result = Math.cos(Math.toRadians(kakudo));
		double rsq = (a * a) + (b * b) - (2 * a * b * result);
		System.out.println(Math.sqrt(rsq));


	}
} Main
import java.util.Scanner;



public class Main {


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int h = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());

		double l = m * 6;
		double s = (h * 60 + m) * 0.5;
		double kakudo = s - l;
		double result = Math.cos(Math.toRadians(kakudo));
		double rsq = (a * a) + (b * b) - (2 * a * b * result);
		System.out.println(Math.sqrt(rsq));


	}
}
