import java.text.DecimalFormat;
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
				Scanner sc = new Scanner(System.in);
		// 整数の入力
		int jisin_nagasa = sc.nextInt();
		int hunsin_nagasa = sc.nextInt();
		int jikan = sc.nextInt();
		int hun = sc.nextInt();

		double jisin_kakudo = (jikan * 60 + hun) * 0.5;
		double hunsin_kakudo = hun * 6;

		double kakudo_sa = 0;

		if (jisin_kakudo > hunsin_kakudo) {
			kakudo_sa = jisin_kakudo - hunsin_kakudo;
		} else {
			kakudo_sa = hunsin_kakudo - jisin_kakudo;
		}

		double b = jisin_nagasa;	//1辺目
		double c = hunsin_nagasa;	//2辺目

		double e = kakudo_sa;			//間の角度

		double r = Math.sqrt(Math.pow(b,2)+Math.pow(c,2) - 2 * b * c * Math.cos(Math.toRadians(e)));

		//この時点でoに数値が入っている
		System.out.println(r);
	}
} import java.text.DecimalFormat; DecimalFormat java.text import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args){
				Scanner sc = new Scanner(System.in);
		// 整数の入力
		int jisin_nagasa = sc.nextInt();
		int hunsin_nagasa = sc.nextInt();
		int jikan = sc.nextInt();
		int hun = sc.nextInt();

		double jisin_kakudo = (jikan * 60 + hun) * 0.5;
		double hunsin_kakudo = hun * 6;

		double kakudo_sa = 0;

		if (jisin_kakudo > hunsin_kakudo) {
			kakudo_sa = jisin_kakudo - hunsin_kakudo;
		} else {
			kakudo_sa = hunsin_kakudo - jisin_kakudo;
		}

		double b = jisin_nagasa;	//1辺目
		double c = hunsin_nagasa;	//2辺目

		double e = kakudo_sa;			//間の角度

		double r = Math.sqrt(Math.pow(b,2)+Math.pow(c,2) - 2 * b * c * Math.cos(Math.toRadians(e)));

		//この時点でoに数値が入っている
		System.out.println(r);
	}
} Main public static void main(String[] args){
				Scanner sc = new Scanner(System.in);
		// 整数の入力
		int jisin_nagasa = sc.nextInt();
		int hunsin_nagasa = sc.nextInt();
		int jikan = sc.nextInt();
		int hun = sc.nextInt();

		double jisin_kakudo = (jikan * 60 + hun) * 0.5;
		double hunsin_kakudo = hun * 6;

		double kakudo_sa = 0;

		if (jisin_kakudo > hunsin_kakudo) {
			kakudo_sa = jisin_kakudo - hunsin_kakudo;
		} else {
			kakudo_sa = hunsin_kakudo - jisin_kakudo;
		}

		double b = jisin_nagasa;	//1辺目
		double c = hunsin_nagasa;	//2辺目

		double e = kakudo_sa;			//間の角度

		double r = Math.sqrt(Math.pow(b,2)+Math.pow(c,2) - 2 * b * c * Math.cos(Math.toRadians(e)));

		//この時点でoに数値が入っている
		System.out.println(r);
	} main {
				Scanner sc = new Scanner(System.in);
		// 整数の入力
		int jisin_nagasa = sc.nextInt();
		int hunsin_nagasa = sc.nextInt();
		int jikan = sc.nextInt();
		int hun = sc.nextInt();

		double jisin_kakudo = (jikan * 60 + hun) * 0.5;
		double hunsin_kakudo = hun * 6;

		double kakudo_sa = 0;

		if (jisin_kakudo > hunsin_kakudo) {
			kakudo_sa = jisin_kakudo - hunsin_kakudo;
		} else {
			kakudo_sa = hunsin_kakudo - jisin_kakudo;
		}

		double b = jisin_nagasa;	//1辺目
		double c = hunsin_nagasa;	//2辺目

		double e = kakudo_sa;			//間の角度

		double r = Math.sqrt(Math.pow(b,2)+Math.pow(c,2) - 2 * b * c * Math.cos(Math.toRadians(e)));

		//この時点でoに数値が入っている
		System.out.println(r);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int jisin_nagasa = sc.nextInt(); jisin_nagasa sc.nextInt() sc.nextInt sc int hunsin_nagasa = sc.nextInt(); hunsin_nagasa sc.nextInt() sc.nextInt sc int jikan = sc.nextInt(); jikan sc.nextInt() sc.nextInt sc int hun = sc.nextInt(); hun sc.nextInt() sc.nextInt sc double jisin_kakudo = (jikan * 60 + hun) * 0.5; jisin_kakudo (jikan * 60 + hun) * 0.5 (jikan * 60 + hun) jikan * 60 jikan 60 hun 0.5 double hunsin_kakudo = hun * 6; hunsin_kakudo hun * 6 hun 6 double kakudo_sa = 0; kakudo_sa 0 if (jisin_kakudo > hunsin_kakudo) {
			kakudo_sa = jisin_kakudo - hunsin_kakudo;
		} else {
			kakudo_sa = hunsin_kakudo - jisin_kakudo;
		} jisin_kakudo > hunsin_kakudo jisin_kakudo hunsin_kakudo {
			kakudo_sa = jisin_kakudo - hunsin_kakudo;
		} kakudo_sa = jisin_kakudo - hunsin_kakudo kakudo_sa jisin_kakudo - hunsin_kakudo jisin_kakudo hunsin_kakudo {
			kakudo_sa = hunsin_kakudo - jisin_kakudo;
		} kakudo_sa = hunsin_kakudo - jisin_kakudo kakudo_sa hunsin_kakudo - jisin_kakudo hunsin_kakudo jisin_kakudo double b = jisin_nagasa; b jisin_nagasa double c = hunsin_nagasa; c hunsin_nagasa double e = kakudo_sa; e kakudo_sa double r = Math.sqrt(Math.pow(b,2)+Math.pow(c,2) - 2 * b * c * Math.cos(Math.toRadians(e))); r Math.sqrt(Math.pow(b,2)+Math.pow(c,2) - 2 * b * c * Math.cos(Math.toRadians(e))) Math.sqrt Math Math.pow(b,2)+Math.pow(c,2) - 2 * b * c * Math.cos(Math.toRadians(e)) Math.pow(b,2)+Math.pow(c,2) Math.pow(b,2) Math.pow Math b 2 Math.pow(c,2) Math.pow Math c 2 2 * b * c * Math.cos(Math.toRadians(e)) c 2 * b * c * Math.cos(Math.toRadians(e)) 2 b c Math.cos(Math.toRadians(e)) Math.cos Math Math.toRadians(e) Math.toRadians Math e System.out.println(r) System.out.println System.out System System.out r String[] args args public class Main {
	public static void main(String[] args){
				Scanner sc = new Scanner(System.in);
		// 整数の入力
		int jisin_nagasa = sc.nextInt();
		int hunsin_nagasa = sc.nextInt();
		int jikan = sc.nextInt();
		int hun = sc.nextInt();

		double jisin_kakudo = (jikan * 60 + hun) * 0.5;
		double hunsin_kakudo = hun * 6;

		double kakudo_sa = 0;

		if (jisin_kakudo > hunsin_kakudo) {
			kakudo_sa = jisin_kakudo - hunsin_kakudo;
		} else {
			kakudo_sa = hunsin_kakudo - jisin_kakudo;
		}

		double b = jisin_nagasa;	//1辺目
		double c = hunsin_nagasa;	//2辺目

		double e = kakudo_sa;			//間の角度

		double r = Math.sqrt(Math.pow(b,2)+Math.pow(c,2) - 2 * b * c * Math.cos(Math.toRadians(e)));

		//この時点でoに数値が入っている
		System.out.println(r);
	}
} public class Main {
	public static void main(String[] args){
				Scanner sc = new Scanner(System.in);
		// 整数の入力
		int jisin_nagasa = sc.nextInt();
		int hunsin_nagasa = sc.nextInt();
		int jikan = sc.nextInt();
		int hun = sc.nextInt();

		double jisin_kakudo = (jikan * 60 + hun) * 0.5;
		double hunsin_kakudo = hun * 6;

		double kakudo_sa = 0;

		if (jisin_kakudo > hunsin_kakudo) {
			kakudo_sa = jisin_kakudo - hunsin_kakudo;
		} else {
			kakudo_sa = hunsin_kakudo - jisin_kakudo;
		}

		double b = jisin_nagasa;	//1辺目
		double c = hunsin_nagasa;	//2辺目

		double e = kakudo_sa;			//間の角度

		double r = Math.sqrt(Math.pow(b,2)+Math.pow(c,2) - 2 * b * c * Math.cos(Math.toRadians(e)));

		//この時点でoに数値が入っている
		System.out.println(r);
	}
} Main
import java.text.DecimalFormat;
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
				Scanner sc = new Scanner(System.in);
		// 整数の入力
		int jisin_nagasa = sc.nextInt();
		int hunsin_nagasa = sc.nextInt();
		int jikan = sc.nextInt();
		int hun = sc.nextInt();

		double jisin_kakudo = (jikan * 60 + hun) * 0.5;
		double hunsin_kakudo = hun * 6;

		double kakudo_sa = 0;

		if (jisin_kakudo > hunsin_kakudo) {
			kakudo_sa = jisin_kakudo - hunsin_kakudo;
		} else {
			kakudo_sa = hunsin_kakudo - jisin_kakudo;
		}

		double b = jisin_nagasa;	//1辺目
		double c = hunsin_nagasa;	//2辺目

		double e = kakudo_sa;			//間の角度

		double r = Math.sqrt(Math.pow(b,2)+Math.pow(c,2) - 2 * b * c * Math.cos(Math.toRadians(e)));

		//この時点でoに数値が入っている
		System.out.println(r);
	}
}