import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    double A = scan.nextDouble();
    double B = scan.nextDouble();
    double H = scan.nextDouble();
    double M = scan.nextDouble();
    double hour, minute, c, co, ans;
    hour = H * 30 + M * 0.5;
    minute = M * 6;
    c = hour - minute;
    if (c > 180) {
      c = 360 - c;
    }
    else if (c < 0) {
      c = 360 + c;
    }
    co = Math.cos(Math.toRadians(c));
    ans = A * A + B * B - 2 * A * B * co;
    System.out.println(Math.sqrt(ans));
  }
}
 import java.util.Scanner; Scanner java.util class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    double A = scan.nextDouble();
    double B = scan.nextDouble();
    double H = scan.nextDouble();
    double M = scan.nextDouble();
    double hour, minute, c, co, ans;
    hour = H * 30 + M * 0.5;
    minute = M * 6;
    c = hour - minute;
    if (c > 180) {
      c = 360 - c;
    }
    else if (c < 0) {
      c = 360 + c;
    }
    co = Math.cos(Math.toRadians(c));
    ans = A * A + B * B - 2 * A * B * co;
    System.out.println(Math.sqrt(ans));
  }
} Main public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    double A = scan.nextDouble();
    double B = scan.nextDouble();
    double H = scan.nextDouble();
    double M = scan.nextDouble();
    double hour, minute, c, co, ans;
    hour = H * 30 + M * 0.5;
    minute = M * 6;
    c = hour - minute;
    if (c > 180) {
      c = 360 - c;
    }
    else if (c < 0) {
      c = 360 + c;
    }
    co = Math.cos(Math.toRadians(c));
    ans = A * A + B * B - 2 * A * B * co;
    System.out.println(Math.sqrt(ans));
  } main {
    Scanner scan = new Scanner(System.in);
    double A = scan.nextDouble();
    double B = scan.nextDouble();
    double H = scan.nextDouble();
    double M = scan.nextDouble();
    double hour, minute, c, co, ans;
    hour = H * 30 + M * 0.5;
    minute = M * 6;
    c = hour - minute;
    if (c > 180) {
      c = 360 - c;
    }
    else if (c < 0) {
      c = 360 + c;
    }
    co = Math.cos(Math.toRadians(c));
    ans = A * A + B * B - 2 * A * B * co;
    System.out.println(Math.sqrt(ans));
  } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) double A = scan.nextDouble(); A scan.nextDouble() scan.nextDouble scan double B = scan.nextDouble(); B scan.nextDouble() scan.nextDouble scan double H = scan.nextDouble(); H scan.nextDouble() scan.nextDouble scan double M = scan.nextDouble(); M scan.nextDouble() scan.nextDouble scan double hour hour minute minute c c co co ans; ans hour = H * 30 + M * 0.5 hour H * 30 + M * 0.5 H * 30 H 30 M * 0.5 M 0.5 minute = M * 6 minute M * 6 M 6 c = hour - minute c hour - minute hour minute if (c > 180) {
      c = 360 - c;
    }
    else if (c < 0) {
      c = 360 + c;
    } c > 180 c 180 {
      c = 360 - c;
    } c = 360 - c c 360 - c 360 c if (c < 0) {
      c = 360 + c;
    } c < 0 c 0 {
      c = 360 + c;
    } c = 360 + c c 360 + c 360 c co = Math.cos(Math.toRadians(c)) co Math.cos(Math.toRadians(c)) Math.cos Math Math.toRadians(c) Math.toRadians Math c ans = A * A + B * B - 2 * A * B * co ans A * A + B * B - 2 * A * B * co A * A + B * B A * A A A B * B B B 2 * A * B * co B 2 * A * B * co 2 A B co System.out.println(Math.sqrt(ans)) System.out.println System.out System System.out Math.sqrt(ans) Math.sqrt Math ans String[] args args
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    double A = scan.nextDouble();
    double B = scan.nextDouble();
    double H = scan.nextDouble();
    double M = scan.nextDouble();
    double hour, minute, c, co, ans;
    hour = H * 30 + M * 0.5;
    minute = M * 6;
    c = hour - minute;
    if (c > 180) {
      c = 360 - c;
    }
    else if (c < 0) {
      c = 360 + c;
    }
    co = Math.cos(Math.toRadians(c));
    ans = A * A + B * B - 2 * A * B * co;
    System.out.println(Math.sqrt(ans));
  }
}

