import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc  = new Scanner(System.in);
    int a = sc.nextInt();//長身
    int b = sc.nextInt();//短針
    int h = sc.nextInt();//時間
    int m = sc.nextInt();//分

    double small = 30 * h + 30 * (double)m/60;
    double big = 360 * (double)m/60;

     // System.out.println(small);
     // System.out.println(big);

    double reg = small - big;
    if(reg>180){
      reg = 360 - reg;
    }else if(reg<-180){
      reg = reg + 360;
    }



    double ans = a*a + b*b - 2 * a * b * Math.cos(Math.toRadians(reg));
     ans = Math.sqrt(ans);
    System.out.println(ans);

  }
} import java.util.*; util.* java public class Main{
  public static void main(String[] args){
    Scanner sc  = new Scanner(System.in);
    int a = sc.nextInt();//長身
    int b = sc.nextInt();//短針
    int h = sc.nextInt();//時間
    int m = sc.nextInt();//分

    double small = 30 * h + 30 * (double)m/60;
    double big = 360 * (double)m/60;

     // System.out.println(small);
     // System.out.println(big);

    double reg = small - big;
    if(reg>180){
      reg = 360 - reg;
    }else if(reg<-180){
      reg = reg + 360;
    }



    double ans = a*a + b*b - 2 * a * b * Math.cos(Math.toRadians(reg));
     ans = Math.sqrt(ans);
    System.out.println(ans);

  }
} Main public static void main(String[] args){
    Scanner sc  = new Scanner(System.in);
    int a = sc.nextInt();//長身
    int b = sc.nextInt();//短針
    int h = sc.nextInt();//時間
    int m = sc.nextInt();//分

    double small = 30 * h + 30 * (double)m/60;
    double big = 360 * (double)m/60;

     // System.out.println(small);
     // System.out.println(big);

    double reg = small - big;
    if(reg>180){
      reg = 360 - reg;
    }else if(reg<-180){
      reg = reg + 360;
    }



    double ans = a*a + b*b - 2 * a * b * Math.cos(Math.toRadians(reg));
     ans = Math.sqrt(ans);
    System.out.println(ans);

  } main {
    Scanner sc  = new Scanner(System.in);
    int a = sc.nextInt();//長身
    int b = sc.nextInt();//短針
    int h = sc.nextInt();//時間
    int m = sc.nextInt();//分

    double small = 30 * h + 30 * (double)m/60;
    double big = 360 * (double)m/60;

     // System.out.println(small);
     // System.out.println(big);

    double reg = small - big;
    if(reg>180){
      reg = 360 - reg;
    }else if(reg<-180){
      reg = reg + 360;
    }



    double ans = a*a + b*b - 2 * a * b * Math.cos(Math.toRadians(reg));
     ans = Math.sqrt(ans);
    System.out.println(ans);

  } 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 h = sc.nextInt(); h sc.nextInt() sc.nextInt sc int m = sc.nextInt(); m sc.nextInt() sc.nextInt sc double small = 30 * h + 30 * (double)m/60; small 30 * h + 30 * (double)m/60 30 * h 30 h 30 * (double)m/60 30 * (double)m 30 (double)m 60 double big = 360 * (double)m/60; big 360 * (double)m/60 360 * (double)m 360 (double)m 60 double reg = small - big; reg small - big small big if(reg>180){
      reg = 360 - reg;
    }else if(reg<-180){
      reg = reg + 360;
    } reg>180 reg 180 {
      reg = 360 - reg;
    } reg = 360 - reg reg 360 - reg 360 reg if(reg<-180){
      reg = reg + 360;
    } reg<-180 reg -180 180 {
      reg = reg + 360;
    } reg = reg + 360 reg reg + 360 reg 360 double ans = a*a + b*b - 2 * a * b * Math.cos(Math.toRadians(reg)); ans a*a + b*b - 2 * a * b * Math.cos(Math.toRadians(reg)) a*a + b*b a*a a a b*b b b 2 * a * b * Math.cos(Math.toRadians(reg)) b 2 * a * b * Math.cos(Math.toRadians(reg)) 2 a b Math.cos(Math.toRadians(reg)) Math.cos Math Math.toRadians(reg) Math.toRadians Math reg ans = Math.sqrt(ans) ans Math.sqrt(ans) Math.sqrt Math ans 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){
    Scanner sc  = new Scanner(System.in);
    int a = sc.nextInt();//長身
    int b = sc.nextInt();//短針
    int h = sc.nextInt();//時間
    int m = sc.nextInt();//分

    double small = 30 * h + 30 * (double)m/60;
    double big = 360 * (double)m/60;

     // System.out.println(small);
     // System.out.println(big);

    double reg = small - big;
    if(reg>180){
      reg = 360 - reg;
    }else if(reg<-180){
      reg = reg + 360;
    }



    double ans = a*a + b*b - 2 * a * b * Math.cos(Math.toRadians(reg));
     ans = Math.sqrt(ans);
    System.out.println(ans);

  }
} public class Main{
  public static void main(String[] args){
    Scanner sc  = new Scanner(System.in);
    int a = sc.nextInt();//長身
    int b = sc.nextInt();//短針
    int h = sc.nextInt();//時間
    int m = sc.nextInt();//分

    double small = 30 * h + 30 * (double)m/60;
    double big = 360 * (double)m/60;

     // System.out.println(small);
     // System.out.println(big);

    double reg = small - big;
    if(reg>180){
      reg = 360 - reg;
    }else if(reg<-180){
      reg = reg + 360;
    }



    double ans = a*a + b*b - 2 * a * b * Math.cos(Math.toRadians(reg));
     ans = Math.sqrt(ans);
    System.out.println(ans);

  }
} Main
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc  = new Scanner(System.in);
    int a = sc.nextInt();//長身
    int b = sc.nextInt();//短針
    int h = sc.nextInt();//時間
    int m = sc.nextInt();//分

    double small = 30 * h + 30 * (double)m/60;
    double big = 360 * (double)m/60;

     // System.out.println(small);
     // System.out.println(big);

    double reg = small - big;
    if(reg>180){
      reg = 360 - reg;
    }else if(reg<-180){
      reg = reg + 360;
    }



    double ans = a*a + b*b - 2 * a * b * Math.cos(Math.toRadians(reg));
     ans = Math.sqrt(ans);
    System.out.println(ans);

  }
}