import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Double.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static final int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		double a = parseDouble(sc.next());
		double b = parseDouble(sc.next());
		double h = parseDouble(sc.next());
		double m = parseDouble(sc.next());
		sc.close();
		double dx = cos(PI*(h/6+m/360)) * a - cos(PI*m/30) * b;
		double dy = sin(PI*(h/6+m/360)) * a - sin(PI*m/30) * b;
		double ans=sqrt(dx*dx+dy*dy);
		out.println(ans);
	}
} import java.util.*; util.* java import java.io.PrintWriter; PrintWriter java.io import static java.lang.Integer.*; import static java.lang.Integer.*; import static java.lang.Integer.*; import static java.lang.Long.*; import static java.lang.Long.*; import static java.lang.Long.*; import static java.lang.Double.*; import static java.lang.Double.*; import static java.lang.Double.*; import static java.lang.Math.*; import static java.lang.Math.*; import static java.lang.Math.*; import static java.lang.System.*; import static java.lang.System.*; import static java.lang.System.*; public class Main {
	public static final int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		double a = parseDouble(sc.next());
		double b = parseDouble(sc.next());
		double h = parseDouble(sc.next());
		double m = parseDouble(sc.next());
		sc.close();
		double dx = cos(PI*(h/6+m/360)) * a - cos(PI*m/30) * b;
		double dy = sin(PI*(h/6+m/360)) * a - sin(PI*m/30) * b;
		double ans=sqrt(dx*dx+dy*dy);
		out.println(ans);
	}
} Main public static final int MOD = 1000000007; MOD 1000000007 public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		double a = parseDouble(sc.next());
		double b = parseDouble(sc.next());
		double h = parseDouble(sc.next());
		double m = parseDouble(sc.next());
		sc.close();
		double dx = cos(PI*(h/6+m/360)) * a - cos(PI*m/30) * b;
		double dy = sin(PI*(h/6+m/360)) * a - sin(PI*m/30) * b;
		double ans=sqrt(dx*dx+dy*dy);
		out.println(ans);
	} main {
		int i,j;
		Scanner sc = new Scanner(in);
		double a = parseDouble(sc.next());
		double b = parseDouble(sc.next());
		double h = parseDouble(sc.next());
		double m = parseDouble(sc.next());
		sc.close();
		double dx = cos(PI*(h/6+m/360)) * a - cos(PI*m/30) * b;
		double dy = sin(PI*(h/6+m/360)) * a - sin(PI*m/30) * b;
		double ans=sqrt(dx*dx+dy*dy);
		out.println(ans);
	} int i i j; j Scanner sc = new Scanner(in); sc new Scanner(in) double a = parseDouble(sc.next()); a parseDouble(sc.next()) parseDouble sc.next() sc.next sc double b = parseDouble(sc.next()); b parseDouble(sc.next()) parseDouble sc.next() sc.next sc double h = parseDouble(sc.next()); h parseDouble(sc.next()) parseDouble sc.next() sc.next sc double m = parseDouble(sc.next()); m parseDouble(sc.next()) parseDouble sc.next() sc.next sc sc.close() sc.close sc double dx = cos(PI*(h/6+m/360)) * a - cos(PI*m/30) * b; dx cos(PI*(h/6+m/360)) * a - cos(PI*m/30) * b cos(PI*(h/6+m/360)) * a cos(PI*(h/6+m/360)) cos PI*(h/6+m/360) PI (h/6+m/360) h/6 h 6 m/360 m 360 a cos(PI*m/30) * b cos(PI*m/30) cos PI*m/30 PI*m PI m 30 b double dy = sin(PI*(h/6+m/360)) * a - sin(PI*m/30) * b; dy sin(PI*(h/6+m/360)) * a - sin(PI*m/30) * b sin(PI*(h/6+m/360)) * a sin(PI*(h/6+m/360)) sin PI*(h/6+m/360) PI (h/6+m/360) h/6 h 6 m/360 m 360 a sin(PI*m/30) * b sin(PI*m/30) sin PI*m/30 PI*m PI m 30 b double ans=sqrt(dx*dx+dy*dy); ans sqrt(dx*dx+dy*dy) sqrt dx*dx+dy*dy dx*dx dx dx dy*dy dy dy out.println(ans) out.println out ans String[] args args public class Main {
	public static final int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		double a = parseDouble(sc.next());
		double b = parseDouble(sc.next());
		double h = parseDouble(sc.next());
		double m = parseDouble(sc.next());
		sc.close();
		double dx = cos(PI*(h/6+m/360)) * a - cos(PI*m/30) * b;
		double dy = sin(PI*(h/6+m/360)) * a - sin(PI*m/30) * b;
		double ans=sqrt(dx*dx+dy*dy);
		out.println(ans);
	}
} public class Main {
	public static final int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		double a = parseDouble(sc.next());
		double b = parseDouble(sc.next());
		double h = parseDouble(sc.next());
		double m = parseDouble(sc.next());
		sc.close();
		double dx = cos(PI*(h/6+m/360)) * a - cos(PI*m/30) * b;
		double dy = sin(PI*(h/6+m/360)) * a - sin(PI*m/30) * b;
		double ans=sqrt(dx*dx+dy*dy);
		out.println(ans);
	}
} Main
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Double.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static final int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		double a = parseDouble(sc.next());
		double b = parseDouble(sc.next());
		double h = parseDouble(sc.next());
		double m = parseDouble(sc.next());
		sc.close();
		double dx = cos(PI*(h/6+m/360)) * a - cos(PI*m/30) * b;
		double dy = sin(PI*(h/6+m/360)) * a - sin(PI*m/30) * b;
		double ans=sqrt(dx*dx+dy*dy);
		out.println(ans);
	}
}
