import java.util.Scanner;

class Main {
	private static double findTheta(int h, int m) {
    	double x = 2*Math.PI / 12 * (h+m/60.0);
		double y = 2*Math.PI / 60 * m;
      	return Math.abs(x-y);
    }
  	private static double findC(int a, int b, double theta) {
    	double c2 = a*a+b*b-2*a*b*Math.cos(theta);
      	return Math.sqrt(c2);
    }
  	public static void main(String[] args) {
    	Scanner in = new Scanner(System.in);
      	int a, b, h, m;
      	a = in.nextInt();
      	b = in.nextInt();
      	h = in.nextInt();
      	m = in.nextInt();
      	double theta = findTheta(h, m);
      	System.out.println(findC(a, b, theta));
    }
} import java.util.Scanner; Scanner java.util class Main {
	private static double findTheta(int h, int m) {
    	double x = 2*Math.PI / 12 * (h+m/60.0);
		double y = 2*Math.PI / 60 * m;
      	return Math.abs(x-y);
    }
  	private static double findC(int a, int b, double theta) {
    	double c2 = a*a+b*b-2*a*b*Math.cos(theta);
      	return Math.sqrt(c2);
    }
  	public static void main(String[] args) {
    	Scanner in = new Scanner(System.in);
      	int a, b, h, m;
      	a = in.nextInt();
      	b = in.nextInt();
      	h = in.nextInt();
      	m = in.nextInt();
      	double theta = findTheta(h, m);
      	System.out.println(findC(a, b, theta));
    }
} Main private static double findTheta(int h, int m) {
    	double x = 2*Math.PI / 12 * (h+m/60.0);
		double y = 2*Math.PI / 60 * m;
      	return Math.abs(x-y);
    } findTheta {
    	double x = 2*Math.PI / 12 * (h+m/60.0);
		double y = 2*Math.PI / 60 * m;
      	return Math.abs(x-y);
    } double x = 2*Math.PI / 12 * (h+m/60.0); x 2*Math.PI / 12 * (h+m/60.0) 2*Math.PI / 12 2*Math.PI 2 Math.PI Math Math.PI 12 (h+m/60.0) h m/60.0 m 60.0 double y = 2*Math.PI / 60 * m; y 2*Math.PI / 60 * m 2*Math.PI / 60 2*Math.PI 2 Math.PI Math Math.PI 60 m return Math.abs(x-y); Math.abs(x-y) Math.abs Math x-y x y int h h int m m private static double findC(int a, int b, double theta) {
    	double c2 = a*a+b*b-2*a*b*Math.cos(theta);
      	return Math.sqrt(c2);
    } findC {
    	double c2 = a*a+b*b-2*a*b*Math.cos(theta);
      	return Math.sqrt(c2);
    } double c2 = a*a+b*b-2*a*b*Math.cos(theta); c2 a*a+b*b-2*a*b*Math.cos(theta) a*a+b*b a*a a a b*b b b 2*a*b*Math.cos(theta) b 2*a*b*Math.cos(theta) 2 a b Math.cos(theta) Math.cos Math theta return Math.sqrt(c2); Math.sqrt(c2) Math.sqrt Math c2 int a a int b b double theta theta public static void main(String[] args) {
    	Scanner in = new Scanner(System.in);
      	int a, b, h, m;
      	a = in.nextInt();
      	b = in.nextInt();
      	h = in.nextInt();
      	m = in.nextInt();
      	double theta = findTheta(h, m);
      	System.out.println(findC(a, b, theta));
    } main {
    	Scanner in = new Scanner(System.in);
      	int a, b, h, m;
      	a = in.nextInt();
      	b = in.nextInt();
      	h = in.nextInt();
      	m = in.nextInt();
      	double theta = findTheta(h, m);
      	System.out.println(findC(a, b, theta));
    } Scanner in = new Scanner(System.in); in new Scanner(System.in) int a a b b h h m; m a = in.nextInt() a in.nextInt() in.nextInt in b = in.nextInt() b in.nextInt() in.nextInt in h = in.nextInt() h in.nextInt() in.nextInt in m = in.nextInt() m in.nextInt() in.nextInt in double theta = findTheta(h, m); theta findTheta(h, m) findTheta h m System.out.println(findC(a, b, theta)) System.out.println System.out System System.out findC(a, b, theta) findC a b theta String[] args args
import java.util.Scanner;

class Main {
	private static double findTheta(int h, int m) {
    	double x = 2*Math.PI / 12 * (h+m/60.0);
		double y = 2*Math.PI / 60 * m;
      	return Math.abs(x-y);
    }
  	private static double findC(int a, int b, double theta) {
    	double c2 = a*a+b*b-2*a*b*Math.cos(theta);
      	return Math.sqrt(c2);
    }
  	public static void main(String[] args) {
    	Scanner in = new Scanner(System.in);
      	int a, b, h, m;
      	a = in.nextInt();
      	b = in.nextInt();
      	h = in.nextInt();
      	m = in.nextInt();
      	double theta = findTheta(h, m);
      	System.out.println(findC(a, b, theta));
    }
}