import java.util.Scanner;
import java.util.ArrayList;
 
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
      ArrayList<String> list = new ArrayList<String>();
      int A,B,H,M;
      int i = 0;
      String an = scan.nextLine();
      String atai[] = an.split(" ",0);
      int num[] = new int[4];
      while(i < 4){
        num[i] = Integer.parseInt(atai[i]);
        i++;
      }
      A = num[0];
      B = num[1];
      H = num[2];
      M = num[3];
//      System.out.println(A+","+B+","+H+","+M);
      check(A,B,H,M);
        scan.close();
    }
  
  public static void check(int a,int b,int h,int m){
   double ang;
   double result,c; 
    ang = ((30*h + 0.5*m) - 6*m);
    ang = Math.abs(ang);
//    System.out.println(ang);
    if(ang == 180){
      result = a+b;
      System.out.println(result);
      return;
    }else if(ang > 180){
      ang = 360 -ang;
//      System.out.println(ang);
    }
    ang = Math.toRadians(ang);
    c = a*a + b*b - 2*a*b*Math.cos(ang);
    result = Math.sqrt(c);
    System.out.println(result);
    return;
  }
} import java.util.Scanner; Scanner java.util import java.util.ArrayList; ArrayList java.util public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
      ArrayList<String> list = new ArrayList<String>();
      int A,B,H,M;
      int i = 0;
      String an = scan.nextLine();
      String atai[] = an.split(" ",0);
      int num[] = new int[4];
      while(i < 4){
        num[i] = Integer.parseInt(atai[i]);
        i++;
      }
      A = num[0];
      B = num[1];
      H = num[2];
      M = num[3];
//      System.out.println(A+","+B+","+H+","+M);
      check(A,B,H,M);
        scan.close();
    }
  
  public static void check(int a,int b,int h,int m){
   double ang;
   double result,c; 
    ang = ((30*h + 0.5*m) - 6*m);
    ang = Math.abs(ang);
//    System.out.println(ang);
    if(ang == 180){
      result = a+b;
      System.out.println(result);
      return;
    }else if(ang > 180){
      ang = 360 -ang;
//      System.out.println(ang);
    }
    ang = Math.toRadians(ang);
    c = a*a + b*b - 2*a*b*Math.cos(ang);
    result = Math.sqrt(c);
    System.out.println(result);
    return;
  }
} Main public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
      ArrayList<String> list = new ArrayList<String>();
      int A,B,H,M;
      int i = 0;
      String an = scan.nextLine();
      String atai[] = an.split(" ",0);
      int num[] = new int[4];
      while(i < 4){
        num[i] = Integer.parseInt(atai[i]);
        i++;
      }
      A = num[0];
      B = num[1];
      H = num[2];
      M = num[3];
//      System.out.println(A+","+B+","+H+","+M);
      check(A,B,H,M);
        scan.close();
    } main {
        Scanner scan = new Scanner(System.in);
      ArrayList<String> list = new ArrayList<String>();
      int A,B,H,M;
      int i = 0;
      String an = scan.nextLine();
      String atai[] = an.split(" ",0);
      int num[] = new int[4];
      while(i < 4){
        num[i] = Integer.parseInt(atai[i]);
        i++;
      }
      A = num[0];
      B = num[1];
      H = num[2];
      M = num[3];
//      System.out.println(A+","+B+","+H+","+M);
      check(A,B,H,M);
        scan.close();
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) ArrayList<String> list = new ArrayList<String>(); list new ArrayList<String>() int A A B B H H M; M int i = 0; i 0 String an = scan.nextLine(); an scan.nextLine() scan.nextLine scan String atai[] = an.split(" ",0); atai an.split(" ",0) an.split an " " 0 int num[] = new int[4]; num new int[4] 4 while(i < 4){
        num[i] = Integer.parseInt(atai[i]);
        i++;
      } i < 4 i 4 {
        num[i] = Integer.parseInt(atai[i]);
        i++;
      } num[i] = Integer.parseInt(atai[i]) num[i] num i Integer.parseInt(atai[i]) Integer.parseInt Integer atai[i] atai i i++ i A = num[0] A num[0] num 0 B = num[1] B num[1] num 1 H = num[2] H num[2] num 2 M = num[3] M num[3] num 3 check(A,B,H,M) check A B H M scan.close() scan.close scan String[] args args public static void check(int a,int b,int h,int m){
   double ang;
   double result,c; 
    ang = ((30*h + 0.5*m) - 6*m);
    ang = Math.abs(ang);
//    System.out.println(ang);
    if(ang == 180){
      result = a+b;
      System.out.println(result);
      return;
    }else if(ang > 180){
      ang = 360 -ang;
//      System.out.println(ang);
    }
    ang = Math.toRadians(ang);
    c = a*a + b*b - 2*a*b*Math.cos(ang);
    result = Math.sqrt(c);
    System.out.println(result);
    return;
  } check {
   double ang;
   double result,c; 
    ang = ((30*h + 0.5*m) - 6*m);
    ang = Math.abs(ang);
//    System.out.println(ang);
    if(ang == 180){
      result = a+b;
      System.out.println(result);
      return;
    }else if(ang > 180){
      ang = 360 -ang;
//      System.out.println(ang);
    }
    ang = Math.toRadians(ang);
    c = a*a + b*b - 2*a*b*Math.cos(ang);
    result = Math.sqrt(c);
    System.out.println(result);
    return;
  } double ang; ang double result result c; c ang = ((30*h + 0.5*m) - 6*m) ang ((30*h + 0.5*m) - 6*m) (30*h + 0.5*m) 30*h 30 h 0.5*m 0.5 m 6*m 6 m ang = Math.abs(ang) ang Math.abs(ang) Math.abs Math ang if(ang == 180){
      result = a+b;
      System.out.println(result);
      return;
    }else if(ang > 180){
      ang = 360 -ang;
//      System.out.println(ang);
    } ang == 180 ang 180 {
      result = a+b;
      System.out.println(result);
      return;
    } result = a+b result a+b a b System.out.println(result) System.out.println System.out System System.out result return; if(ang > 180){
      ang = 360 -ang;
//      System.out.println(ang);
    } ang > 180 ang 180 {
      ang = 360 -ang;
//      System.out.println(ang);
    } ang = 360 -ang ang 360 -ang 360 ang ang = Math.toRadians(ang) ang Math.toRadians(ang) Math.toRadians Math ang c = a*a + b*b - 2*a*b*Math.cos(ang) c a*a + b*b - 2*a*b*Math.cos(ang) a*a + b*b a*a a a b*b b b 2*a*b*Math.cos(ang) b 2*a*b*Math.cos(ang) 2 a b Math.cos(ang) Math.cos Math ang result = Math.sqrt(c) result Math.sqrt(c) Math.sqrt Math c System.out.println(result) System.out.println System.out System System.out result return; int a a int b b int h h int m m public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
      ArrayList<String> list = new ArrayList<String>();
      int A,B,H,M;
      int i = 0;
      String an = scan.nextLine();
      String atai[] = an.split(" ",0);
      int num[] = new int[4];
      while(i < 4){
        num[i] = Integer.parseInt(atai[i]);
        i++;
      }
      A = num[0];
      B = num[1];
      H = num[2];
      M = num[3];
//      System.out.println(A+","+B+","+H+","+M);
      check(A,B,H,M);
        scan.close();
    }
  
  public static void check(int a,int b,int h,int m){
   double ang;
   double result,c; 
    ang = ((30*h + 0.5*m) - 6*m);
    ang = Math.abs(ang);
//    System.out.println(ang);
    if(ang == 180){
      result = a+b;
      System.out.println(result);
      return;
    }else if(ang > 180){
      ang = 360 -ang;
//      System.out.println(ang);
    }
    ang = Math.toRadians(ang);
    c = a*a + b*b - 2*a*b*Math.cos(ang);
    result = Math.sqrt(c);
    System.out.println(result);
    return;
  }
} public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
      ArrayList<String> list = new ArrayList<String>();
      int A,B,H,M;
      int i = 0;
      String an = scan.nextLine();
      String atai[] = an.split(" ",0);
      int num[] = new int[4];
      while(i < 4){
        num[i] = Integer.parseInt(atai[i]);
        i++;
      }
      A = num[0];
      B = num[1];
      H = num[2];
      M = num[3];
//      System.out.println(A+","+B+","+H+","+M);
      check(A,B,H,M);
        scan.close();
    }
  
  public static void check(int a,int b,int h,int m){
   double ang;
   double result,c; 
    ang = ((30*h + 0.5*m) - 6*m);
    ang = Math.abs(ang);
//    System.out.println(ang);
    if(ang == 180){
      result = a+b;
      System.out.println(result);
      return;
    }else if(ang > 180){
      ang = 360 -ang;
//      System.out.println(ang);
    }
    ang = Math.toRadians(ang);
    c = a*a + b*b - 2*a*b*Math.cos(ang);
    result = Math.sqrt(c);
    System.out.println(result);
    return;
  }
} Main
import java.util.Scanner;
import java.util.ArrayList;
 
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
      ArrayList<String> list = new ArrayList<String>();
      int A,B,H,M;
      int i = 0;
      String an = scan.nextLine();
      String atai[] = an.split(" ",0);
      int num[] = new int[4];
      while(i < 4){
        num[i] = Integer.parseInt(atai[i]);
        i++;
      }
      A = num[0];
      B = num[1];
      H = num[2];
      M = num[3];
//      System.out.println(A+","+B+","+H+","+M);
      check(A,B,H,M);
        scan.close();
    }
  
  public static void check(int a,int b,int h,int m){
   double ang;
   double result,c; 
    ang = ((30*h + 0.5*m) - 6*m);
    ang = Math.abs(ang);
//    System.out.println(ang);
    if(ang == 180){
      result = a+b;
      System.out.println(result);
      return;
    }else if(ang > 180){
      ang = 360 -ang;
//      System.out.println(ang);
    }
    ang = Math.toRadians(ang);
    c = a*a + b*b - 2*a*b*Math.cos(ang);
    result = Math.sqrt(c);
    System.out.println(result);
    return;
  }
}