import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int A=scan.nextInt();
		int B=scan.nextInt();
		int H=scan.nextInt();
		int M=scan.nextInt();
		double wm=360/60;
		double wh1=360/12;
		double wh2=30.0/60.0;
		double m_angle=(double)M*wm;
		double h_angle=(double)H*wh1+(double)M*wh2;
		double angle_a=m_angle>h_angle ? m_angle-h_angle : h_angle-m_angle;
		if(angle_a>180)angle_a=360-angle_a;
		double b=Math.pow(A,2);
		double c=Math.pow(B, 2);
		
		double a=Math.sqrt(b+c-2*A*B*Math.cos(Math.toRadians(angle_a)));
		System.out.println(a);

	}

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

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int A=scan.nextInt();
		int B=scan.nextInt();
		int H=scan.nextInt();
		int M=scan.nextInt();
		double wm=360/60;
		double wh1=360/12;
		double wh2=30.0/60.0;
		double m_angle=(double)M*wm;
		double h_angle=(double)H*wh1+(double)M*wh2;
		double angle_a=m_angle>h_angle ? m_angle-h_angle : h_angle-m_angle;
		if(angle_a>180)angle_a=360-angle_a;
		double b=Math.pow(A,2);
		double c=Math.pow(B, 2);
		
		double a=Math.sqrt(b+c-2*A*B*Math.cos(Math.toRadians(angle_a)));
		System.out.println(a);

	}

} Main public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int A=scan.nextInt();
		int B=scan.nextInt();
		int H=scan.nextInt();
		int M=scan.nextInt();
		double wm=360/60;
		double wh1=360/12;
		double wh2=30.0/60.0;
		double m_angle=(double)M*wm;
		double h_angle=(double)H*wh1+(double)M*wh2;
		double angle_a=m_angle>h_angle ? m_angle-h_angle : h_angle-m_angle;
		if(angle_a>180)angle_a=360-angle_a;
		double b=Math.pow(A,2);
		double c=Math.pow(B, 2);
		
		double a=Math.sqrt(b+c-2*A*B*Math.cos(Math.toRadians(angle_a)));
		System.out.println(a);

	} main {
		Scanner scan=new Scanner(System.in);
		int A=scan.nextInt();
		int B=scan.nextInt();
		int H=scan.nextInt();
		int M=scan.nextInt();
		double wm=360/60;
		double wh1=360/12;
		double wh2=30.0/60.0;
		double m_angle=(double)M*wm;
		double h_angle=(double)H*wh1+(double)M*wh2;
		double angle_a=m_angle>h_angle ? m_angle-h_angle : h_angle-m_angle;
		if(angle_a>180)angle_a=360-angle_a;
		double b=Math.pow(A,2);
		double c=Math.pow(B, 2);
		
		double a=Math.sqrt(b+c-2*A*B*Math.cos(Math.toRadians(angle_a)));
		System.out.println(a);

	} 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 wm=360/60; wm 360/60 360 60 double wh1=360/12; wh1 360/12 360 12 double wh2=30.0/60.0; wh2 30.0/60.0 30.0 60.0 double m_angle=(double)M*wm; m_angle (double)M*wm (double)M wm double h_angle=(double)H*wh1+(double)M*wh2; h_angle (double)H*wh1+(double)M*wh2 (double)H*wh1 (double)H wh1 (double)M*wh2 (double)M wh2 double angle_a=m_angle>h_angle ? m_angle-h_angle : h_angle-m_angle; angle_a m_angle>h_angle ? m_angle-h_angle : h_angle-m_angle m_angle>h_angle m_angle h_angle m_angle-h_angle m_angle h_angle h_angle-m_angle h_angle m_angle if(angle_a>180)angle_a=360-angle_a; angle_a>180 angle_a 180 angle_a=360-angle_a angle_a 360-angle_a 360 angle_a double b=Math.pow(A,2); b Math.pow(A,2) Math.pow Math A 2 double c=Math.pow(B, 2); c Math.pow(B, 2) Math.pow Math B 2 double a=Math.sqrt(b+c-2*A*B*Math.cos(Math.toRadians(angle_a))); a Math.sqrt(b+c-2*A*B*Math.cos(Math.toRadians(angle_a))) Math.sqrt Math b+c-2*A*B*Math.cos(Math.toRadians(angle_a)) b+c b c 2*A*B*Math.cos(Math.toRadians(angle_a)) B 2*A*B*Math.cos(Math.toRadians(angle_a)) 2 A B Math.cos(Math.toRadians(angle_a)) Math.cos Math Math.toRadians(angle_a) Math.toRadians Math angle_a System.out.println(a) System.out.println System.out System System.out a String[] args args public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int A=scan.nextInt();
		int B=scan.nextInt();
		int H=scan.nextInt();
		int M=scan.nextInt();
		double wm=360/60;
		double wh1=360/12;
		double wh2=30.0/60.0;
		double m_angle=(double)M*wm;
		double h_angle=(double)H*wh1+(double)M*wh2;
		double angle_a=m_angle>h_angle ? m_angle-h_angle : h_angle-m_angle;
		if(angle_a>180)angle_a=360-angle_a;
		double b=Math.pow(A,2);
		double c=Math.pow(B, 2);
		
		double a=Math.sqrt(b+c-2*A*B*Math.cos(Math.toRadians(angle_a)));
		System.out.println(a);

	}

} public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int A=scan.nextInt();
		int B=scan.nextInt();
		int H=scan.nextInt();
		int M=scan.nextInt();
		double wm=360/60;
		double wh1=360/12;
		double wh2=30.0/60.0;
		double m_angle=(double)M*wm;
		double h_angle=(double)H*wh1+(double)M*wh2;
		double angle_a=m_angle>h_angle ? m_angle-h_angle : h_angle-m_angle;
		if(angle_a>180)angle_a=360-angle_a;
		double b=Math.pow(A,2);
		double c=Math.pow(B, 2);
		
		double a=Math.sqrt(b+c-2*A*B*Math.cos(Math.toRadians(angle_a)));
		System.out.println(a);

	}

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

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int A=scan.nextInt();
		int B=scan.nextInt();
		int H=scan.nextInt();
		int M=scan.nextInt();
		double wm=360/60;
		double wh1=360/12;
		double wh2=30.0/60.0;
		double m_angle=(double)M*wm;
		double h_angle=(double)H*wh1+(double)M*wh2;
		double angle_a=m_angle>h_angle ? m_angle-h_angle : h_angle-m_angle;
		if(angle_a>180)angle_a=360-angle_a;
		double b=Math.pow(A,2);
		double c=Math.pow(B, 2);
		
		double a=Math.sqrt(b+c-2*A*B*Math.cos(Math.toRadians(angle_a)));
		System.out.println(a);

	}

}