import java.util.*;
import java.lang.Math;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int H = sc.nextInt();
    int M = sc.nextInt();
    double s;

    
    double sA = 30 * H + 0.5 * M;
    double sB = 6 * M;
    
    if(sA <= sB) {
     s = sB - sA;
    } else {
     s = sA - sB;
    }
    
    double ans2 = A*A + B*B - 2*A*B*Math.cos(Math.toRadians(s));
    System.out.println(Math.sqrt(ans2));
  }
} import java.util.*; util.* java import java.lang.Math; Math java.lang public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int H = sc.nextInt();
    int M = sc.nextInt();
    double s;

    
    double sA = 30 * H + 0.5 * M;
    double sB = 6 * M;
    
    if(sA <= sB) {
     s = sB - sA;
    } else {
     s = sA - sB;
    }
    
    double ans2 = A*A + B*B - 2*A*B*Math.cos(Math.toRadians(s));
    System.out.println(Math.sqrt(ans2));
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int H = sc.nextInt();
    int M = sc.nextInt();
    double s;

    
    double sA = 30 * H + 0.5 * M;
    double sB = 6 * M;
    
    if(sA <= sB) {
     s = sB - sA;
    } else {
     s = sA - sB;
    }
    
    double ans2 = A*A + B*B - 2*A*B*Math.cos(Math.toRadians(s));
    System.out.println(Math.sqrt(ans2));
  } main {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int H = sc.nextInt();
    int M = sc.nextInt();
    double s;

    
    double sA = 30 * H + 0.5 * M;
    double sB = 6 * M;
    
    if(sA <= sB) {
     s = sB - sA;
    } else {
     s = sA - sB;
    }
    
    double ans2 = A*A + B*B - 2*A*B*Math.cos(Math.toRadians(s));
    System.out.println(Math.sqrt(ans2));
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int A = sc.nextInt(); A sc.nextInt() sc.nextInt sc int B = sc.nextInt(); B sc.nextInt() sc.nextInt sc int H = sc.nextInt(); H sc.nextInt() sc.nextInt sc int M = sc.nextInt(); M sc.nextInt() sc.nextInt sc double s; s double sA = 30 * H + 0.5 * M; sA 30 * H + 0.5 * M 30 * H 30 H 0.5 * M 0.5 M double sB = 6 * M; sB 6 * M 6 M if(sA <= sB) {
     s = sB - sA;
    } else {
     s = sA - sB;
    } sA <= sB sA sB {
     s = sB - sA;
    } s = sB - sA s sB - sA sB sA {
     s = sA - sB;
    } s = sA - sB s sA - sB sA sB double ans2 = A*A + B*B - 2*A*B*Math.cos(Math.toRadians(s)); ans2 A*A + B*B - 2*A*B*Math.cos(Math.toRadians(s)) A*A + B*B A*A A A B*B B B 2*A*B*Math.cos(Math.toRadians(s)) B 2*A*B*Math.cos(Math.toRadians(s)) 2 A B Math.cos(Math.toRadians(s)) Math.cos Math Math.toRadians(s) Math.toRadians Math s System.out.println(Math.sqrt(ans2)) System.out.println System.out System System.out Math.sqrt(ans2) Math.sqrt Math ans2 String[] args args public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int H = sc.nextInt();
    int M = sc.nextInt();
    double s;

    
    double sA = 30 * H + 0.5 * M;
    double sB = 6 * M;
    
    if(sA <= sB) {
     s = sB - sA;
    } else {
     s = sA - sB;
    }
    
    double ans2 = A*A + B*B - 2*A*B*Math.cos(Math.toRadians(s));
    System.out.println(Math.sqrt(ans2));
  }
} public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int H = sc.nextInt();
    int M = sc.nextInt();
    double s;

    
    double sA = 30 * H + 0.5 * M;
    double sB = 6 * M;
    
    if(sA <= sB) {
     s = sB - sA;
    } else {
     s = sA - sB;
    }
    
    double ans2 = A*A + B*B - 2*A*B*Math.cos(Math.toRadians(s));
    System.out.println(Math.sqrt(ans2));
  }
} Main
import java.util.*;
import java.lang.Math;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int H = sc.nextInt();
    int M = sc.nextInt();
    double s;

    
    double sA = 30 * H + 0.5 * M;
    double sB = 6 * M;
    
    if(sA <= sB) {
     s = sB - sA;
    } else {
     s = sA - sB;
    }
    
    double ans2 = A*A + B*B - 2*A*B*Math.cos(Math.toRadians(s));
    System.out.println(Math.sqrt(ans2));
  }
}