import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		double a = scn.nextDouble();
      double b = scn.nextDouble();
      double h = scn.nextDouble();
      double m = scn.nextDouble();
      double hh = h*30 + m/2;
      double mm = m*6;
      double x =hh - mm; 
      double cosx = Math.cos(Math.toRadians(x));
      double ans2 = a*a + b*b - 2*a*b*cosx;
      double ans = Math.sqrt(ans2);
      System.out.println(ans);
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		double a = scn.nextDouble();
      double b = scn.nextDouble();
      double h = scn.nextDouble();
      double m = scn.nextDouble();
      double hh = h*30 + m/2;
      double mm = m*6;
      double x =hh - mm; 
      double cosx = Math.cos(Math.toRadians(x));
      double ans2 = a*a + b*b - 2*a*b*cosx;
      double ans = Math.sqrt(ans2);
      System.out.println(ans);
	}
} Main public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		double a = scn.nextDouble();
      double b = scn.nextDouble();
      double h = scn.nextDouble();
      double m = scn.nextDouble();
      double hh = h*30 + m/2;
      double mm = m*6;
      double x =hh - mm; 
      double cosx = Math.cos(Math.toRadians(x));
      double ans2 = a*a + b*b - 2*a*b*cosx;
      double ans = Math.sqrt(ans2);
      System.out.println(ans);
	} main {
		Scanner scn = new Scanner(System.in);
		double a = scn.nextDouble();
      double b = scn.nextDouble();
      double h = scn.nextDouble();
      double m = scn.nextDouble();
      double hh = h*30 + m/2;
      double mm = m*6;
      double x =hh - mm; 
      double cosx = Math.cos(Math.toRadians(x));
      double ans2 = a*a + b*b - 2*a*b*cosx;
      double ans = Math.sqrt(ans2);
      System.out.println(ans);
	} Scanner scn = new Scanner(System.in); scn new Scanner(System.in) double a = scn.nextDouble(); a scn.nextDouble() scn.nextDouble scn double b = scn.nextDouble(); b scn.nextDouble() scn.nextDouble scn double h = scn.nextDouble(); h scn.nextDouble() scn.nextDouble scn double m = scn.nextDouble(); m scn.nextDouble() scn.nextDouble scn double hh = h*30 + m/2; hh h*30 + m/2 h*30 h 30 m/2 m 2 double mm = m*6; mm m*6 m 6 double x =hh - mm; x hh - mm hh mm double cosx = Math.cos(Math.toRadians(x)); cosx Math.cos(Math.toRadians(x)) Math.cos Math Math.toRadians(x) Math.toRadians Math x double ans2 = a*a + b*b - 2*a*b*cosx; ans2 a*a + b*b - 2*a*b*cosx a*a + b*b a*a a a b*b b b 2*a*b*cosx b 2*a*b*cosx 2 a b cosx double ans = Math.sqrt(ans2); ans Math.sqrt(ans2) Math.sqrt Math ans2 System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		double a = scn.nextDouble();
      double b = scn.nextDouble();
      double h = scn.nextDouble();
      double m = scn.nextDouble();
      double hh = h*30 + m/2;
      double mm = m*6;
      double x =hh - mm; 
      double cosx = Math.cos(Math.toRadians(x));
      double ans2 = a*a + b*b - 2*a*b*cosx;
      double ans = Math.sqrt(ans2);
      System.out.println(ans);
	}
} public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		double a = scn.nextDouble();
      double b = scn.nextDouble();
      double h = scn.nextDouble();
      double m = scn.nextDouble();
      double hh = h*30 + m/2;
      double mm = m*6;
      double x =hh - mm; 
      double cosx = Math.cos(Math.toRadians(x));
      double ans2 = a*a + b*b - 2*a*b*cosx;
      double ans = Math.sqrt(ans2);
      System.out.println(ans);
	}
} Main
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		double a = scn.nextDouble();
      double b = scn.nextDouble();
      double h = scn.nextDouble();
      double m = scn.nextDouble();
      double hh = h*30 + m/2;
      double mm = m*6;
      double x =hh - mm; 
      double cosx = Math.cos(Math.toRadians(x));
      double ans2 = a*a + b*b - 2*a*b*cosx;
      double ans = Math.sqrt(ans2);
      System.out.println(ans);
	}
}
