import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt(); //A cm 時針
    int B = sc.nextInt(); //B cm 分針
    double H = sc.nextInt(); //時
    double M = sc.nextInt(); //分
    
    //時針の0時からの傾き
    double Y = 360 * (H / 12)+30*(M/60);
    //分針の0時からの傾き
    double X = 360 * (M / 60);
    //求める角度
    double angle = X - Y;
    //求める長さ
    double C = 0.00000000000000;
    C = A*A + B*B - 2*A*B*Math.cos(Math.toRadians(angle));
    
    //System.out.println(angle);
    System.out.println(Math.sqrt(C));
    
   
  }
} import java.util.Scanner; Scanner java.util class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt(); //A cm 時針
    int B = sc.nextInt(); //B cm 分針
    double H = sc.nextInt(); //時
    double M = sc.nextInt(); //分
    
    //時針の0時からの傾き
    double Y = 360 * (H / 12)+30*(M/60);
    //分針の0時からの傾き
    double X = 360 * (M / 60);
    //求める角度
    double angle = X - Y;
    //求める長さ
    double C = 0.00000000000000;
    C = A*A + B*B - 2*A*B*Math.cos(Math.toRadians(angle));
    
    //System.out.println(angle);
    System.out.println(Math.sqrt(C));
    
   
  }
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt(); //A cm 時針
    int B = sc.nextInt(); //B cm 分針
    double H = sc.nextInt(); //時
    double M = sc.nextInt(); //分
    
    //時針の0時からの傾き
    double Y = 360 * (H / 12)+30*(M/60);
    //分針の0時からの傾き
    double X = 360 * (M / 60);
    //求める角度
    double angle = X - Y;
    //求める長さ
    double C = 0.00000000000000;
    C = A*A + B*B - 2*A*B*Math.cos(Math.toRadians(angle));
    
    //System.out.println(angle);
    System.out.println(Math.sqrt(C));
    
   
  } main {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt(); //A cm 時針
    int B = sc.nextInt(); //B cm 分針
    double H = sc.nextInt(); //時
    double M = sc.nextInt(); //分
    
    //時針の0時からの傾き
    double Y = 360 * (H / 12)+30*(M/60);
    //分針の0時からの傾き
    double X = 360 * (M / 60);
    //求める角度
    double angle = X - Y;
    //求める長さ
    double C = 0.00000000000000;
    C = A*A + B*B - 2*A*B*Math.cos(Math.toRadians(angle));
    
    //System.out.println(angle);
    System.out.println(Math.sqrt(C));
    
   
  } 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 double H = sc.nextInt(); H sc.nextInt() sc.nextInt sc double M = sc.nextInt(); M sc.nextInt() sc.nextInt sc double Y = 360 * (H / 12)+30*(M/60); Y 360 * (H / 12)+30*(M/60) 360 * (H / 12) 360 (H / 12) H 12 30*(M/60) 30 (M/60) M 60 double X = 360 * (M / 60); X 360 * (M / 60) 360 (M / 60) M 60 double angle = X - Y; angle X - Y X Y double C = 0.00000000000000; C 0.00000000000000 C = A*A + B*B - 2*A*B*Math.cos(Math.toRadians(angle)) C A*A + B*B - 2*A*B*Math.cos(Math.toRadians(angle)) A*A + B*B A*A A A B*B B B 2*A*B*Math.cos(Math.toRadians(angle)) B 2*A*B*Math.cos(Math.toRadians(angle)) 2 A B Math.cos(Math.toRadians(angle)) Math.cos Math Math.toRadians(angle) Math.toRadians Math angle System.out.println(Math.sqrt(C)) System.out.println System.out System System.out Math.sqrt(C) Math.sqrt Math C String[] args args
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt(); //A cm 時針
    int B = sc.nextInt(); //B cm 分針
    double H = sc.nextInt(); //時
    double M = sc.nextInt(); //分
    
    //時針の0時からの傾き
    double Y = 360 * (H / 12)+30*(M/60);
    //分針の0時からの傾き
    double X = 360 * (M / 60);
    //求める角度
    double angle = X - Y;
    //求める長さ
    double C = 0.00000000000000;
    C = A*A + B*B - 2*A*B*Math.cos(Math.toRadians(angle));
    
    //System.out.println(angle);
    System.out.println(Math.sqrt(C));
    
   
  }
}