import java.util.Scanner;
import java.util.ArrayList;

public class Main {
  public static void main(String[] args) {
    // 標準入力取得
    Scanner sc = new Scanner(System.in);    
    String iShortNeedle = sc.next();
    String iLongNeedle = sc.next();
    String h = sc.next();
    String m = sc.next();
    // 入力値加工
    double hour = Double.parseDouble(h);
    double min = Double.parseDouble(m);
    double wholeMin = (hour*60) + min;
    double shortNeedle = Double.parseDouble(iShortNeedle);
    double longNeedle = Double.parseDouble(iLongNeedle);

// check
//    System.out.println("shortNlength:" + shortNeedle + "cm");
//    System.out.println("longNlength:" + longNeedle + "cm");
//    System.out.println("hour:" + hour + "H");
//    System.out.println("min:" + min + "min");
//    System.out.println("wholeMin: "+ wholeMin + "min");

    double shortAngleByOneMin = (360.0/12.0)/60.0;
    double longAngleByOneMin = 360.0/60.0;
//    System.out.println("1分で短針が動く度数: "+ shortAngleByOneMin + "°");
//    System.out.println("1分で長針が動く度数: "+ longAngleByOneMin + "°");
//    System.out.println("XX分で短針が動く度数: "+ shortAngleByOneMin * wholeMin);
//    System.out.println("XX分で長針が動く度数: "+ longAngleByOneMin * min);

    // 各針の角度を計算する
    double rHour = 0; 
    double rMin = 0;
    if(wholeMin!=0){
      rHour = shortAngleByOneMin * wholeMin; 
    }
    if(min!=0){
      rMin = longAngleByOneMin * min;
    }
    double diffAngle = Math.abs(rHour - rMin);    

// check
//    System.out.println("rHour: " + rHour + "°");
//    System.out.println("rMin: " + rMin + "°");
//    System.out.println("diffAngle: " + diffAngle + "°");

    double aLength = 0;
    if(diffAngle!=0 || diffAngle!=180){
	  aLength = Math.sqrt( Math.pow(shortNeedle,2) + Math.pow(longNeedle,2) - 2 * shortNeedle * longNeedle * Math.cos(Math.toRadians(diffAngle)) );
    }else if(diffAngle==0){
      aLength = longNeedle - shortNeedle;    
    }else if(diffAngle==180){
      aLength = longNeedle + shortNeedle;
    }
    
//answer
    System.out.println(aLength);
  }
} import java.util.Scanner; Scanner java.util import java.util.ArrayList; ArrayList java.util public class Main {
  public static void main(String[] args) {
    // 標準入力取得
    Scanner sc = new Scanner(System.in);    
    String iShortNeedle = sc.next();
    String iLongNeedle = sc.next();
    String h = sc.next();
    String m = sc.next();
    // 入力値加工
    double hour = Double.parseDouble(h);
    double min = Double.parseDouble(m);
    double wholeMin = (hour*60) + min;
    double shortNeedle = Double.parseDouble(iShortNeedle);
    double longNeedle = Double.parseDouble(iLongNeedle);

// check
//    System.out.println("shortNlength:" + shortNeedle + "cm");
//    System.out.println("longNlength:" + longNeedle + "cm");
//    System.out.println("hour:" + hour + "H");
//    System.out.println("min:" + min + "min");
//    System.out.println("wholeMin: "+ wholeMin + "min");

    double shortAngleByOneMin = (360.0/12.0)/60.0;
    double longAngleByOneMin = 360.0/60.0;
//    System.out.println("1分で短針が動く度数: "+ shortAngleByOneMin + "°");
//    System.out.println("1分で長針が動く度数: "+ longAngleByOneMin + "°");
//    System.out.println("XX分で短針が動く度数: "+ shortAngleByOneMin * wholeMin);
//    System.out.println("XX分で長針が動く度数: "+ longAngleByOneMin * min);

    // 各針の角度を計算する
    double rHour = 0; 
    double rMin = 0;
    if(wholeMin!=0){
      rHour = shortAngleByOneMin * wholeMin; 
    }
    if(min!=0){
      rMin = longAngleByOneMin * min;
    }
    double diffAngle = Math.abs(rHour - rMin);    

// check
//    System.out.println("rHour: " + rHour + "°");
//    System.out.println("rMin: " + rMin + "°");
//    System.out.println("diffAngle: " + diffAngle + "°");

    double aLength = 0;
    if(diffAngle!=0 || diffAngle!=180){
	  aLength = Math.sqrt( Math.pow(shortNeedle,2) + Math.pow(longNeedle,2) - 2 * shortNeedle * longNeedle * Math.cos(Math.toRadians(diffAngle)) );
    }else if(diffAngle==0){
      aLength = longNeedle - shortNeedle;    
    }else if(diffAngle==180){
      aLength = longNeedle + shortNeedle;
    }
    
//answer
    System.out.println(aLength);
  }
} Main public static void main(String[] args) {
    // 標準入力取得
    Scanner sc = new Scanner(System.in);    
    String iShortNeedle = sc.next();
    String iLongNeedle = sc.next();
    String h = sc.next();
    String m = sc.next();
    // 入力値加工
    double hour = Double.parseDouble(h);
    double min = Double.parseDouble(m);
    double wholeMin = (hour*60) + min;
    double shortNeedle = Double.parseDouble(iShortNeedle);
    double longNeedle = Double.parseDouble(iLongNeedle);

// check
//    System.out.println("shortNlength:" + shortNeedle + "cm");
//    System.out.println("longNlength:" + longNeedle + "cm");
//    System.out.println("hour:" + hour + "H");
//    System.out.println("min:" + min + "min");
//    System.out.println("wholeMin: "+ wholeMin + "min");

    double shortAngleByOneMin = (360.0/12.0)/60.0;
    double longAngleByOneMin = 360.0/60.0;
//    System.out.println("1分で短針が動く度数: "+ shortAngleByOneMin + "°");
//    System.out.println("1分で長針が動く度数: "+ longAngleByOneMin + "°");
//    System.out.println("XX分で短針が動く度数: "+ shortAngleByOneMin * wholeMin);
//    System.out.println("XX分で長針が動く度数: "+ longAngleByOneMin * min);

    // 各針の角度を計算する
    double rHour = 0; 
    double rMin = 0;
    if(wholeMin!=0){
      rHour = shortAngleByOneMin * wholeMin; 
    }
    if(min!=0){
      rMin = longAngleByOneMin * min;
    }
    double diffAngle = Math.abs(rHour - rMin);    

// check
//    System.out.println("rHour: " + rHour + "°");
//    System.out.println("rMin: " + rMin + "°");
//    System.out.println("diffAngle: " + diffAngle + "°");

    double aLength = 0;
    if(diffAngle!=0 || diffAngle!=180){
	  aLength = Math.sqrt( Math.pow(shortNeedle,2) + Math.pow(longNeedle,2) - 2 * shortNeedle * longNeedle * Math.cos(Math.toRadians(diffAngle)) );
    }else if(diffAngle==0){
      aLength = longNeedle - shortNeedle;    
    }else if(diffAngle==180){
      aLength = longNeedle + shortNeedle;
    }
    
//answer
    System.out.println(aLength);
  } main {
    // 標準入力取得
    Scanner sc = new Scanner(System.in);    
    String iShortNeedle = sc.next();
    String iLongNeedle = sc.next();
    String h = sc.next();
    String m = sc.next();
    // 入力値加工
    double hour = Double.parseDouble(h);
    double min = Double.parseDouble(m);
    double wholeMin = (hour*60) + min;
    double shortNeedle = Double.parseDouble(iShortNeedle);
    double longNeedle = Double.parseDouble(iLongNeedle);

// check
//    System.out.println("shortNlength:" + shortNeedle + "cm");
//    System.out.println("longNlength:" + longNeedle + "cm");
//    System.out.println("hour:" + hour + "H");
//    System.out.println("min:" + min + "min");
//    System.out.println("wholeMin: "+ wholeMin + "min");

    double shortAngleByOneMin = (360.0/12.0)/60.0;
    double longAngleByOneMin = 360.0/60.0;
//    System.out.println("1分で短針が動く度数: "+ shortAngleByOneMin + "°");
//    System.out.println("1分で長針が動く度数: "+ longAngleByOneMin + "°");
//    System.out.println("XX分で短針が動く度数: "+ shortAngleByOneMin * wholeMin);
//    System.out.println("XX分で長針が動く度数: "+ longAngleByOneMin * min);

    // 各針の角度を計算する
    double rHour = 0; 
    double rMin = 0;
    if(wholeMin!=0){
      rHour = shortAngleByOneMin * wholeMin; 
    }
    if(min!=0){
      rMin = longAngleByOneMin * min;
    }
    double diffAngle = Math.abs(rHour - rMin);    

// check
//    System.out.println("rHour: " + rHour + "°");
//    System.out.println("rMin: " + rMin + "°");
//    System.out.println("diffAngle: " + diffAngle + "°");

    double aLength = 0;
    if(diffAngle!=0 || diffAngle!=180){
	  aLength = Math.sqrt( Math.pow(shortNeedle,2) + Math.pow(longNeedle,2) - 2 * shortNeedle * longNeedle * Math.cos(Math.toRadians(diffAngle)) );
    }else if(diffAngle==0){
      aLength = longNeedle - shortNeedle;    
    }else if(diffAngle==180){
      aLength = longNeedle + shortNeedle;
    }
    
//answer
    System.out.println(aLength);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String iShortNeedle = sc.next(); iShortNeedle sc.next() sc.next sc String iLongNeedle = sc.next(); iLongNeedle sc.next() sc.next sc String h = sc.next(); h sc.next() sc.next sc String m = sc.next(); m sc.next() sc.next sc double hour = Double.parseDouble(h); hour Double.parseDouble(h) Double.parseDouble Double h double min = Double.parseDouble(m); min Double.parseDouble(m) Double.parseDouble Double m double wholeMin = (hour*60) + min; wholeMin (hour*60) + min (hour*60) hour 60 min double shortNeedle = Double.parseDouble(iShortNeedle); shortNeedle Double.parseDouble(iShortNeedle) Double.parseDouble Double iShortNeedle double longNeedle = Double.parseDouble(iLongNeedle); longNeedle Double.parseDouble(iLongNeedle) Double.parseDouble Double iLongNeedle double shortAngleByOneMin = (360.0/12.0)/60.0; shortAngleByOneMin (360.0/12.0)/60.0 (360.0/12.0) 360.0 12.0 60.0 double longAngleByOneMin = 360.0/60.0; longAngleByOneMin 360.0/60.0 360.0 60.0 double rHour = 0; rHour 0 double rMin = 0; rMin 0 if(wholeMin!=0){
      rHour = shortAngleByOneMin * wholeMin; 
    } wholeMin!=0 wholeMin 0 {
      rHour = shortAngleByOneMin * wholeMin; 
    } rHour = shortAngleByOneMin * wholeMin rHour shortAngleByOneMin * wholeMin shortAngleByOneMin wholeMin if(min!=0){
      rMin = longAngleByOneMin * min;
    } min!=0 min 0 {
      rMin = longAngleByOneMin * min;
    } rMin = longAngleByOneMin * min rMin longAngleByOneMin * min longAngleByOneMin min double diffAngle = Math.abs(rHour - rMin); diffAngle Math.abs(rHour - rMin) Math.abs Math rHour - rMin rHour rMin double aLength = 0; aLength 0 if(diffAngle!=0 || diffAngle!=180){
	  aLength = Math.sqrt( Math.pow(shortNeedle,2) + Math.pow(longNeedle,2) - 2 * shortNeedle * longNeedle * Math.cos(Math.toRadians(diffAngle)) );
    }else if(diffAngle==0){
      aLength = longNeedle - shortNeedle;    
    }else if(diffAngle==180){
      aLength = longNeedle + shortNeedle;
    } diffAngle!=0 || diffAngle!=180 diffAngle!=0 diffAngle 0 diffAngle!=180 diffAngle 180 {
	  aLength = Math.sqrt( Math.pow(shortNeedle,2) + Math.pow(longNeedle,2) - 2 * shortNeedle * longNeedle * Math.cos(Math.toRadians(diffAngle)) );
    } aLength = Math.sqrt( Math.pow(shortNeedle,2) + Math.pow(longNeedle,2) - 2 * shortNeedle * longNeedle * Math.cos(Math.toRadians(diffAngle)) ) aLength Math.sqrt( Math.pow(shortNeedle,2) + Math.pow(longNeedle,2) - 2 * shortNeedle * longNeedle * Math.cos(Math.toRadians(diffAngle)) ) Math.sqrt Math Math.pow(shortNeedle,2) + Math.pow(longNeedle,2) - 2 * shortNeedle * longNeedle * Math.cos(Math.toRadians(diffAngle)) Math.pow(shortNeedle,2) + Math.pow(longNeedle,2) Math.pow(shortNeedle,2) Math.pow Math shortNeedle 2 Math.pow(longNeedle,2) Math.pow Math longNeedle 2 2 * shortNeedle * longNeedle * Math.cos(Math.toRadians(diffAngle)) longNeedle 2 * shortNeedle * longNeedle * Math.cos(Math.toRadians(diffAngle)) 2 shortNeedle longNeedle Math.cos(Math.toRadians(diffAngle)) Math.cos Math Math.toRadians(diffAngle) Math.toRadians Math diffAngle if(diffAngle==0){
      aLength = longNeedle - shortNeedle;    
    }else if(diffAngle==180){
      aLength = longNeedle + shortNeedle;
    } diffAngle==0 diffAngle 0 {
      aLength = longNeedle - shortNeedle;    
    } aLength = longNeedle - shortNeedle aLength longNeedle - shortNeedle longNeedle shortNeedle if(diffAngle==180){
      aLength = longNeedle + shortNeedle;
    } diffAngle==180 diffAngle 180 {
      aLength = longNeedle + shortNeedle;
    } aLength = longNeedle + shortNeedle aLength longNeedle + shortNeedle longNeedle shortNeedle System.out.println(aLength) System.out.println System.out System System.out aLength String[] args args public class Main {
  public static void main(String[] args) {
    // 標準入力取得
    Scanner sc = new Scanner(System.in);    
    String iShortNeedle = sc.next();
    String iLongNeedle = sc.next();
    String h = sc.next();
    String m = sc.next();
    // 入力値加工
    double hour = Double.parseDouble(h);
    double min = Double.parseDouble(m);
    double wholeMin = (hour*60) + min;
    double shortNeedle = Double.parseDouble(iShortNeedle);
    double longNeedle = Double.parseDouble(iLongNeedle);

// check
//    System.out.println("shortNlength:" + shortNeedle + "cm");
//    System.out.println("longNlength:" + longNeedle + "cm");
//    System.out.println("hour:" + hour + "H");
//    System.out.println("min:" + min + "min");
//    System.out.println("wholeMin: "+ wholeMin + "min");

    double shortAngleByOneMin = (360.0/12.0)/60.0;
    double longAngleByOneMin = 360.0/60.0;
//    System.out.println("1分で短針が動く度数: "+ shortAngleByOneMin + "°");
//    System.out.println("1分で長針が動く度数: "+ longAngleByOneMin + "°");
//    System.out.println("XX分で短針が動く度数: "+ shortAngleByOneMin * wholeMin);
//    System.out.println("XX分で長針が動く度数: "+ longAngleByOneMin * min);

    // 各針の角度を計算する
    double rHour = 0; 
    double rMin = 0;
    if(wholeMin!=0){
      rHour = shortAngleByOneMin * wholeMin; 
    }
    if(min!=0){
      rMin = longAngleByOneMin * min;
    }
    double diffAngle = Math.abs(rHour - rMin);    

// check
//    System.out.println("rHour: " + rHour + "°");
//    System.out.println("rMin: " + rMin + "°");
//    System.out.println("diffAngle: " + diffAngle + "°");

    double aLength = 0;
    if(diffAngle!=0 || diffAngle!=180){
	  aLength = Math.sqrt( Math.pow(shortNeedle,2) + Math.pow(longNeedle,2) - 2 * shortNeedle * longNeedle * Math.cos(Math.toRadians(diffAngle)) );
    }else if(diffAngle==0){
      aLength = longNeedle - shortNeedle;    
    }else if(diffAngle==180){
      aLength = longNeedle + shortNeedle;
    }
    
//answer
    System.out.println(aLength);
  }
} public class Main {
  public static void main(String[] args) {
    // 標準入力取得
    Scanner sc = new Scanner(System.in);    
    String iShortNeedle = sc.next();
    String iLongNeedle = sc.next();
    String h = sc.next();
    String m = sc.next();
    // 入力値加工
    double hour = Double.parseDouble(h);
    double min = Double.parseDouble(m);
    double wholeMin = (hour*60) + min;
    double shortNeedle = Double.parseDouble(iShortNeedle);
    double longNeedle = Double.parseDouble(iLongNeedle);

// check
//    System.out.println("shortNlength:" + shortNeedle + "cm");
//    System.out.println("longNlength:" + longNeedle + "cm");
//    System.out.println("hour:" + hour + "H");
//    System.out.println("min:" + min + "min");
//    System.out.println("wholeMin: "+ wholeMin + "min");

    double shortAngleByOneMin = (360.0/12.0)/60.0;
    double longAngleByOneMin = 360.0/60.0;
//    System.out.println("1分で短針が動く度数: "+ shortAngleByOneMin + "°");
//    System.out.println("1分で長針が動く度数: "+ longAngleByOneMin + "°");
//    System.out.println("XX分で短針が動く度数: "+ shortAngleByOneMin * wholeMin);
//    System.out.println("XX分で長針が動く度数: "+ longAngleByOneMin * min);

    // 各針の角度を計算する
    double rHour = 0; 
    double rMin = 0;
    if(wholeMin!=0){
      rHour = shortAngleByOneMin * wholeMin; 
    }
    if(min!=0){
      rMin = longAngleByOneMin * min;
    }
    double diffAngle = Math.abs(rHour - rMin);    

// check
//    System.out.println("rHour: " + rHour + "°");
//    System.out.println("rMin: " + rMin + "°");
//    System.out.println("diffAngle: " + diffAngle + "°");

    double aLength = 0;
    if(diffAngle!=0 || diffAngle!=180){
	  aLength = Math.sqrt( Math.pow(shortNeedle,2) + Math.pow(longNeedle,2) - 2 * shortNeedle * longNeedle * Math.cos(Math.toRadians(diffAngle)) );
    }else if(diffAngle==0){
      aLength = longNeedle - shortNeedle;    
    }else if(diffAngle==180){
      aLength = longNeedle + shortNeedle;
    }
    
//answer
    System.out.println(aLength);
  }
} Main
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
  public static void main(String[] args) {
    // 標準入力取得
    Scanner sc = new Scanner(System.in);    
    String iShortNeedle = sc.next();
    String iLongNeedle = sc.next();
    String h = sc.next();
    String m = sc.next();
    // 入力値加工
    double hour = Double.parseDouble(h);
    double min = Double.parseDouble(m);
    double wholeMin = (hour*60) + min;
    double shortNeedle = Double.parseDouble(iShortNeedle);
    double longNeedle = Double.parseDouble(iLongNeedle);

// check
//    System.out.println("shortNlength:" + shortNeedle + "cm");
//    System.out.println("longNlength:" + longNeedle + "cm");
//    System.out.println("hour:" + hour + "H");
//    System.out.println("min:" + min + "min");
//    System.out.println("wholeMin: "+ wholeMin + "min");

    double shortAngleByOneMin = (360.0/12.0)/60.0;
    double longAngleByOneMin = 360.0/60.0;
//    System.out.println("1分で短針が動く度数: "+ shortAngleByOneMin + "°");
//    System.out.println("1分で長針が動く度数: "+ longAngleByOneMin + "°");
//    System.out.println("XX分で短針が動く度数: "+ shortAngleByOneMin * wholeMin);
//    System.out.println("XX分で長針が動く度数: "+ longAngleByOneMin * min);

    // 各針の角度を計算する
    double rHour = 0; 
    double rMin = 0;
    if(wholeMin!=0){
      rHour = shortAngleByOneMin * wholeMin; 
    }
    if(min!=0){
      rMin = longAngleByOneMin * min;
    }
    double diffAngle = Math.abs(rHour - rMin);    

// check
//    System.out.println("rHour: " + rHour + "°");
//    System.out.println("rMin: " + rMin + "°");
//    System.out.println("diffAngle: " + diffAngle + "°");

    double aLength = 0;
    if(diffAngle!=0 || diffAngle!=180){
	  aLength = Math.sqrt( Math.pow(shortNeedle,2) + Math.pow(longNeedle,2) - 2 * shortNeedle * longNeedle * Math.cos(Math.toRadians(diffAngle)) );
    }else if(diffAngle==0){
      aLength = longNeedle - shortNeedle;    
    }else if(diffAngle==180){
      aLength = longNeedle + shortNeedle;
    }
    
//answer
    System.out.println(aLength);
  }
}