import java.util.*;
class Main{
public static void main(String[]args){
Scanner sc=new Scanner(System.in);
  int a=sc.nextInt();
  int b=sc.nextInt();
  int c=sc.nextInt();
  int d=sc.nextInt();
  double x=c*30;
  double y=d*6;
  x+=d*0.5;
  x=(x-y)*Math.PI/180;
  System.out.println(Math.sqrt(a*a+b*b-2*a*b*Math.cos(x)));
}
} import java.util.*; util.* java class Main{
public static void main(String[]args){
Scanner sc=new Scanner(System.in);
  int a=sc.nextInt();
  int b=sc.nextInt();
  int c=sc.nextInt();
  int d=sc.nextInt();
  double x=c*30;
  double y=d*6;
  x+=d*0.5;
  x=(x-y)*Math.PI/180;
  System.out.println(Math.sqrt(a*a+b*b-2*a*b*Math.cos(x)));
}
} Main public static void main(String[]args){
Scanner sc=new Scanner(System.in);
  int a=sc.nextInt();
  int b=sc.nextInt();
  int c=sc.nextInt();
  int d=sc.nextInt();
  double x=c*30;
  double y=d*6;
  x+=d*0.5;
  x=(x-y)*Math.PI/180;
  System.out.println(Math.sqrt(a*a+b*b-2*a*b*Math.cos(x)));
} main {
Scanner sc=new Scanner(System.in);
  int a=sc.nextInt();
  int b=sc.nextInt();
  int c=sc.nextInt();
  int d=sc.nextInt();
  double x=c*30;
  double y=d*6;
  x+=d*0.5;
  x=(x-y)*Math.PI/180;
  System.out.println(Math.sqrt(a*a+b*b-2*a*b*Math.cos(x)));
} Scanner sc=new Scanner(System.in); sc new Scanner(System.in) int a=sc.nextInt(); a sc.nextInt() sc.nextInt sc int b=sc.nextInt(); b sc.nextInt() sc.nextInt sc int c=sc.nextInt(); c sc.nextInt() sc.nextInt sc int d=sc.nextInt(); d sc.nextInt() sc.nextInt sc double x=c*30; x c*30 c 30 double y=d*6; y d*6 d 6 x+=d*0.5 x d*0.5 d 0.5 x=(x-y)*Math.PI/180 x (x-y)*Math.PI/180 (x-y)*Math.PI (x-y) x y Math.PI Math Math.PI 180 System.out.println(Math.sqrt(a*a+b*b-2*a*b*Math.cos(x))) System.out.println System.out System System.out Math.sqrt(a*a+b*b-2*a*b*Math.cos(x)) Math.sqrt Math a*a+b*b-2*a*b*Math.cos(x) a*a+b*b a*a a a b*b b b 2*a*b*Math.cos(x) b 2*a*b*Math.cos(x) 2 a b Math.cos(x) Math.cos Math x String[]args args
import java.util.*;
class Main{
public static void main(String[]args){
Scanner sc=new Scanner(System.in);
  int a=sc.nextInt();
  int b=sc.nextInt();
  int c=sc.nextInt();
  int d=sc.nextInt();
  double x=c*30;
  double y=d*6;
  x+=d*0.5;
  x=(x-y)*Math.PI/180;
  System.out.println(Math.sqrt(a*a+b*b-2*a*b*Math.cos(x)));
}
}
