import java.util.Scanner;

public class Main{
 public static void main(String[] args) {
   Scanner kbd =new Scanner(System.in);
    int a=kbd.nextInt();
    int b=kbd.nextInt();
    int h=kbd.nextInt();
    int m=kbd.nextInt();

    double A=h*30+m*0.5;
    double B=m*6;
    double C=0;
    if(A-B>=0){
      C=A-B;
    }else{
      C=B-A;
    }
    if(C>180){
      C=360-C;
    }
    C=Math.toRadians(C);
    double x=b*Math.sin(C)*b*Math.sin(C);
    double y=(b*Math.cos(C)-a)*(b*Math.cos(C)-a);
    System.out.println(Math.sqrt(x+y));
 }
} import java.util.Scanner; Scanner java.util public class Main{
 public static void main(String[] args) {
   Scanner kbd =new Scanner(System.in);
    int a=kbd.nextInt();
    int b=kbd.nextInt();
    int h=kbd.nextInt();
    int m=kbd.nextInt();

    double A=h*30+m*0.5;
    double B=m*6;
    double C=0;
    if(A-B>=0){
      C=A-B;
    }else{
      C=B-A;
    }
    if(C>180){
      C=360-C;
    }
    C=Math.toRadians(C);
    double x=b*Math.sin(C)*b*Math.sin(C);
    double y=(b*Math.cos(C)-a)*(b*Math.cos(C)-a);
    System.out.println(Math.sqrt(x+y));
 }
} Main public static void main(String[] args) {
   Scanner kbd =new Scanner(System.in);
    int a=kbd.nextInt();
    int b=kbd.nextInt();
    int h=kbd.nextInt();
    int m=kbd.nextInt();

    double A=h*30+m*0.5;
    double B=m*6;
    double C=0;
    if(A-B>=0){
      C=A-B;
    }else{
      C=B-A;
    }
    if(C>180){
      C=360-C;
    }
    C=Math.toRadians(C);
    double x=b*Math.sin(C)*b*Math.sin(C);
    double y=(b*Math.cos(C)-a)*(b*Math.cos(C)-a);
    System.out.println(Math.sqrt(x+y));
 } main {
   Scanner kbd =new Scanner(System.in);
    int a=kbd.nextInt();
    int b=kbd.nextInt();
    int h=kbd.nextInt();
    int m=kbd.nextInt();

    double A=h*30+m*0.5;
    double B=m*6;
    double C=0;
    if(A-B>=0){
      C=A-B;
    }else{
      C=B-A;
    }
    if(C>180){
      C=360-C;
    }
    C=Math.toRadians(C);
    double x=b*Math.sin(C)*b*Math.sin(C);
    double y=(b*Math.cos(C)-a)*(b*Math.cos(C)-a);
    System.out.println(Math.sqrt(x+y));
 } Scanner kbd =new Scanner(System.in); kbd new Scanner(System.in) int a=kbd.nextInt(); a kbd.nextInt() kbd.nextInt kbd int b=kbd.nextInt(); b kbd.nextInt() kbd.nextInt kbd int h=kbd.nextInt(); h kbd.nextInt() kbd.nextInt kbd int m=kbd.nextInt(); m kbd.nextInt() kbd.nextInt kbd double A=h*30+m*0.5; A h*30+m*0.5 h*30 h 30 m*0.5 m 0.5 double B=m*6; B m*6 m 6 double C=0; C 0 if(A-B>=0){
      C=A-B;
    }else{
      C=B-A;
    } A-B>=0 A-B A B 0 {
      C=A-B;
    } C=A-B C A-B A B {
      C=B-A;
    } C=B-A C B-A B A if(C>180){
      C=360-C;
    } C>180 C 180 {
      C=360-C;
    } C=360-C C 360-C 360 C C=Math.toRadians(C) C Math.toRadians(C) Math.toRadians Math C double x=b*Math.sin(C)*b*Math.sin(C); x b*Math.sin(C)*b*Math.sin(C) b b*Math.sin(C)*b*Math.sin(C) b Math.sin(C) Math.sin Math C b Math.sin(C) Math.sin Math C double y=(b*Math.cos(C)-a)*(b*Math.cos(C)-a); y (b*Math.cos(C)-a)*(b*Math.cos(C)-a) (b*Math.cos(C)-a) b*Math.cos(C) b Math.cos(C) Math.cos Math C a (b*Math.cos(C)-a) b*Math.cos(C) b Math.cos(C) Math.cos Math C a System.out.println(Math.sqrt(x+y)) System.out.println System.out System System.out Math.sqrt(x+y) Math.sqrt Math x+y x y String[] args args public class Main{
 public static void main(String[] args) {
   Scanner kbd =new Scanner(System.in);
    int a=kbd.nextInt();
    int b=kbd.nextInt();
    int h=kbd.nextInt();
    int m=kbd.nextInt();

    double A=h*30+m*0.5;
    double B=m*6;
    double C=0;
    if(A-B>=0){
      C=A-B;
    }else{
      C=B-A;
    }
    if(C>180){
      C=360-C;
    }
    C=Math.toRadians(C);
    double x=b*Math.sin(C)*b*Math.sin(C);
    double y=(b*Math.cos(C)-a)*(b*Math.cos(C)-a);
    System.out.println(Math.sqrt(x+y));
 }
} public class Main{
 public static void main(String[] args) {
   Scanner kbd =new Scanner(System.in);
    int a=kbd.nextInt();
    int b=kbd.nextInt();
    int h=kbd.nextInt();
    int m=kbd.nextInt();

    double A=h*30+m*0.5;
    double B=m*6;
    double C=0;
    if(A-B>=0){
      C=A-B;
    }else{
      C=B-A;
    }
    if(C>180){
      C=360-C;
    }
    C=Math.toRadians(C);
    double x=b*Math.sin(C)*b*Math.sin(C);
    double y=(b*Math.cos(C)-a)*(b*Math.cos(C)-a);
    System.out.println(Math.sqrt(x+y));
 }
} Main
import java.util.Scanner;

public class Main{
 public static void main(String[] args) {
   Scanner kbd =new Scanner(System.in);
    int a=kbd.nextInt();
    int b=kbd.nextInt();
    int h=kbd.nextInt();
    int m=kbd.nextInt();

    double A=h*30+m*0.5;
    double B=m*6;
    double C=0;
    if(A-B>=0){
      C=A-B;
    }else{
      C=B-A;
    }
    if(C>180){
      C=360-C;
    }
    C=Math.toRadians(C);
    double x=b*Math.sin(C)*b*Math.sin(C);
    double y=(b*Math.cos(C)-a)*(b*Math.cos(C)-a);
    System.out.println(Math.sqrt(x+y));
 }
}