import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    double a = sc.nextDouble();
    double b = sc.nextDouble();
    int h = sc.nextInt();
    int m = sc.nextInt();
    int D = (60 * h) + m;
    double dd = (double)D;
    double a1 = dd / (double)2;
    double a2 = dd * ((double)6);
    a1 = (a1 % 360);
    a2 = (a2 % 360);
    double a3 = Math.abs(a1 - a2);
    double a3r = Math.toRadians(a3);
    double cos = Math.cos(a3r);
    double ans = (a * a) + (b * b) - (2 * a * b * cos);
    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);
    double a = sc.nextDouble();
    double b = sc.nextDouble();
    int h = sc.nextInt();
    int m = sc.nextInt();
    int D = (60 * h) + m;
    double dd = (double)D;
    double a1 = dd / (double)2;
    double a2 = dd * ((double)6);
    a1 = (a1 % 360);
    a2 = (a2 % 360);
    double a3 = Math.abs(a1 - a2);
    double a3r = Math.toRadians(a3);
    double cos = Math.cos(a3r);
    double ans = (a * a) + (b * b) - (2 * a * b * cos);
    ans = Math.sqrt(ans); 
    System.out.println(ans);
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    double a = sc.nextDouble();
    double b = sc.nextDouble();
    int h = sc.nextInt();
    int m = sc.nextInt();
    int D = (60 * h) + m;
    double dd = (double)D;
    double a1 = dd / (double)2;
    double a2 = dd * ((double)6);
    a1 = (a1 % 360);
    a2 = (a2 % 360);
    double a3 = Math.abs(a1 - a2);
    double a3r = Math.toRadians(a3);
    double cos = Math.cos(a3r);
    double ans = (a * a) + (b * b) - (2 * a * b * cos);
    ans = Math.sqrt(ans); 
    System.out.println(ans);
  } main {
    Scanner sc = new Scanner(System.in);
    double a = sc.nextDouble();
    double b = sc.nextDouble();
    int h = sc.nextInt();
    int m = sc.nextInt();
    int D = (60 * h) + m;
    double dd = (double)D;
    double a1 = dd / (double)2;
    double a2 = dd * ((double)6);
    a1 = (a1 % 360);
    a2 = (a2 % 360);
    double a3 = Math.abs(a1 - a2);
    double a3r = Math.toRadians(a3);
    double cos = Math.cos(a3r);
    double ans = (a * a) + (b * b) - (2 * a * b * cos);
    ans = Math.sqrt(ans); 
    System.out.println(ans);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) double a = sc.nextDouble(); a sc.nextDouble() sc.nextDouble sc double b = sc.nextDouble(); b sc.nextDouble() sc.nextDouble sc int h = sc.nextInt(); h sc.nextInt() sc.nextInt sc int m = sc.nextInt(); m sc.nextInt() sc.nextInt sc int D = (60 * h) + m; D (60 * h) + m (60 * h) 60 h m double dd = (double)D; dd (double)D double a1 = dd / (double)2; a1 dd / (double)2 dd (double)2 double a2 = dd * ((double)6); a2 dd * ((double)6) dd ((double)6) a1 = (a1 % 360) a1 (a1 % 360) a1 360 a2 = (a2 % 360) a2 (a2 % 360) a2 360 double a3 = Math.abs(a1 - a2); a3 Math.abs(a1 - a2) Math.abs Math a1 - a2 a1 a2 double a3r = Math.toRadians(a3); a3r Math.toRadians(a3) Math.toRadians Math a3 double cos = Math.cos(a3r); cos Math.cos(a3r) Math.cos Math a3r double ans = (a * a) + (b * b) - (2 * a * b * cos); ans (a * a) + (b * b) - (2 * a * b * cos) (a * a) + (b * b) (a * a) a a (b * b) b b (2 * a * b * cos) b 2 * a * b * cos 2 a b cos 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);
    double a = sc.nextDouble();
    double b = sc.nextDouble();
    int h = sc.nextInt();
    int m = sc.nextInt();
    int D = (60 * h) + m;
    double dd = (double)D;
    double a1 = dd / (double)2;
    double a2 = dd * ((double)6);
    a1 = (a1 % 360);
    a2 = (a2 % 360);
    double a3 = Math.abs(a1 - a2);
    double a3r = Math.toRadians(a3);
    double cos = Math.cos(a3r);
    double ans = (a * a) + (b * b) - (2 * a * b * cos);
    ans = Math.sqrt(ans); 
    System.out.println(ans);
  }
} public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    double a = sc.nextDouble();
    double b = sc.nextDouble();
    int h = sc.nextInt();
    int m = sc.nextInt();
    int D = (60 * h) + m;
    double dd = (double)D;
    double a1 = dd / (double)2;
    double a2 = dd * ((double)6);
    a1 = (a1 % 360);
    a2 = (a2 % 360);
    double a3 = Math.abs(a1 - a2);
    double a3r = Math.toRadians(a3);
    double cos = Math.cos(a3r);
    double ans = (a * a) + (b * b) - (2 * a * b * cos);
    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);
    double a = sc.nextDouble();
    double b = sc.nextDouble();
    int h = sc.nextInt();
    int m = sc.nextInt();
    int D = (60 * h) + m;
    double dd = (double)D;
    double a1 = dd / (double)2;
    double a2 = dd * ((double)6);
    a1 = (a1 % 360);
    a2 = (a2 % 360);
    double a3 = Math.abs(a1 - a2);
    double a3r = Math.toRadians(a3);
    double cos = Math.cos(a3r);
    double ans = (a * a) + (b * b) - (2 * a * b * cos);
    ans = Math.sqrt(ans); 
    System.out.println(ans);
  }
}
