import java.util.*;
import java.math.BigInteger;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    double pai = Math.PI;
    double a = sc.nextDouble();
    double b = sc.nextDouble();
    double h = sc.nextDouble();
    double m = sc.nextDouble();
    // 時針は分針にも影響されることに注意
    double cosC = Math.cos(Math.abs(30*(h+m/60) - 6*m) / 180 * pai);
    double ansPow = b*b + a*a - 2*a*b*cosC;
    System.out.println(Math.pow(ansPow, 0.5));
  }
} import java.util.*; util.* java import java.math.BigInteger; BigInteger java.math public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    double pai = Math.PI;
    double a = sc.nextDouble();
    double b = sc.nextDouble();
    double h = sc.nextDouble();
    double m = sc.nextDouble();
    // 時針は分針にも影響されることに注意
    double cosC = Math.cos(Math.abs(30*(h+m/60) - 6*m) / 180 * pai);
    double ansPow = b*b + a*a - 2*a*b*cosC;
    System.out.println(Math.pow(ansPow, 0.5));
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    double pai = Math.PI;
    double a = sc.nextDouble();
    double b = sc.nextDouble();
    double h = sc.nextDouble();
    double m = sc.nextDouble();
    // 時針は分針にも影響されることに注意
    double cosC = Math.cos(Math.abs(30*(h+m/60) - 6*m) / 180 * pai);
    double ansPow = b*b + a*a - 2*a*b*cosC;
    System.out.println(Math.pow(ansPow, 0.5));
  } main {
    Scanner sc = new Scanner(System.in);
    double pai = Math.PI;
    double a = sc.nextDouble();
    double b = sc.nextDouble();
    double h = sc.nextDouble();
    double m = sc.nextDouble();
    // 時針は分針にも影響されることに注意
    double cosC = Math.cos(Math.abs(30*(h+m/60) - 6*m) / 180 * pai);
    double ansPow = b*b + a*a - 2*a*b*cosC;
    System.out.println(Math.pow(ansPow, 0.5));
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) double pai = Math.PI; pai Math.PI Math Math.PI double a = sc.nextDouble(); a sc.nextDouble() sc.nextDouble sc double b = sc.nextDouble(); b sc.nextDouble() sc.nextDouble sc double h = sc.nextDouble(); h sc.nextDouble() sc.nextDouble sc double m = sc.nextDouble(); m sc.nextDouble() sc.nextDouble sc double cosC = Math.cos(Math.abs(30*(h+m/60) - 6*m) / 180 * pai); cosC Math.cos(Math.abs(30*(h+m/60) - 6*m) / 180 * pai) Math.cos Math Math.abs(30*(h+m/60) - 6*m) / 180 * pai Math.abs(30*(h+m/60) - 6*m) / 180 Math.abs(30*(h+m/60) - 6*m) Math.abs Math 30*(h+m/60) - 6*m 30*(h+m/60) 30 (h+m/60) h m/60 m 60 6*m 6 m 180 pai double ansPow = b*b + a*a - 2*a*b*cosC; ansPow b*b + a*a - 2*a*b*cosC b*b + a*a b*b b b a*a a a 2*a*b*cosC b 2*a*b*cosC 2 a b cosC System.out.println(Math.pow(ansPow, 0.5)) System.out.println System.out System System.out Math.pow(ansPow, 0.5) Math.pow Math ansPow 0.5 String[] args args public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    double pai = Math.PI;
    double a = sc.nextDouble();
    double b = sc.nextDouble();
    double h = sc.nextDouble();
    double m = sc.nextDouble();
    // 時針は分針にも影響されることに注意
    double cosC = Math.cos(Math.abs(30*(h+m/60) - 6*m) / 180 * pai);
    double ansPow = b*b + a*a - 2*a*b*cosC;
    System.out.println(Math.pow(ansPow, 0.5));
  }
} public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    double pai = Math.PI;
    double a = sc.nextDouble();
    double b = sc.nextDouble();
    double h = sc.nextDouble();
    double m = sc.nextDouble();
    // 時針は分針にも影響されることに注意
    double cosC = Math.cos(Math.abs(30*(h+m/60) - 6*m) / 180 * pai);
    double ansPow = b*b + a*a - 2*a*b*cosC;
    System.out.println(Math.pow(ansPow, 0.5));
  }
} Main
import java.util.*;
import java.math.BigInteger;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    double pai = Math.PI;
    double a = sc.nextDouble();
    double b = sc.nextDouble();
    double h = sc.nextDouble();
    double m = sc.nextDouble();
    // 時針は分針にも影響されることに注意
    double cosC = Math.cos(Math.abs(30*(h+m/60) - 6*m) / 180 * pai);
    double ansPow = b*b + a*a - 2*a*b*cosC;
    System.out.println(Math.pow(ansPow, 0.5));
  }
}
