import java.util.Scanner;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.HashSet;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    Double A=sc.nextDouble();
    Double B=sc.nextDouble();
    Double H=sc.nextDouble();
    Double M=sc.nextDouble();
    Double kakudo=Math.abs(H*30+30*(M/60)-M*6);
    if(kakudo>360-kakudo){
      kakudo=360-kakudo;
    }


    System.out.println(Math.sqrt(Math.pow(A,2)+Math.pow(B,2)-2*A*B*Math.cos(Math.toRadians(kakudo))));

  }
} import java.util.Scanner; Scanner java.util import java.util.Arrays; Arrays java.util import java.util.ArrayList; ArrayList java.util import java.util.List; List java.util import java.util.stream.Collectors; Collectors java.util.stream import java.util.HashSet; HashSet java.util class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    Double A=sc.nextDouble();
    Double B=sc.nextDouble();
    Double H=sc.nextDouble();
    Double M=sc.nextDouble();
    Double kakudo=Math.abs(H*30+30*(M/60)-M*6);
    if(kakudo>360-kakudo){
      kakudo=360-kakudo;
    }


    System.out.println(Math.sqrt(Math.pow(A,2)+Math.pow(B,2)-2*A*B*Math.cos(Math.toRadians(kakudo))));

  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    Double A=sc.nextDouble();
    Double B=sc.nextDouble();
    Double H=sc.nextDouble();
    Double M=sc.nextDouble();
    Double kakudo=Math.abs(H*30+30*(M/60)-M*6);
    if(kakudo>360-kakudo){
      kakudo=360-kakudo;
    }


    System.out.println(Math.sqrt(Math.pow(A,2)+Math.pow(B,2)-2*A*B*Math.cos(Math.toRadians(kakudo))));

  } main {
    Scanner sc = new Scanner(System.in);
    Double A=sc.nextDouble();
    Double B=sc.nextDouble();
    Double H=sc.nextDouble();
    Double M=sc.nextDouble();
    Double kakudo=Math.abs(H*30+30*(M/60)-M*6);
    if(kakudo>360-kakudo){
      kakudo=360-kakudo;
    }


    System.out.println(Math.sqrt(Math.pow(A,2)+Math.pow(B,2)-2*A*B*Math.cos(Math.toRadians(kakudo))));

  } 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 Double H=sc.nextDouble(); H sc.nextDouble() sc.nextDouble sc Double M=sc.nextDouble(); M sc.nextDouble() sc.nextDouble sc Double kakudo=Math.abs(H*30+30*(M/60)-M*6); kakudo Math.abs(H*30+30*(M/60)-M*6) Math.abs Math H*30+30*(M/60)-M*6 H*30+30*(M/60) H*30 H 30 30*(M/60) 30 (M/60) M 60 M*6 M 6 if(kakudo>360-kakudo){
      kakudo=360-kakudo;
    } kakudo>360-kakudo kakudo 360-kakudo 360 kakudo {
      kakudo=360-kakudo;
    } kakudo=360-kakudo kakudo 360-kakudo 360 kakudo System.out.println(Math.sqrt(Math.pow(A,2)+Math.pow(B,2)-2*A*B*Math.cos(Math.toRadians(kakudo)))) System.out.println System.out System System.out Math.sqrt(Math.pow(A,2)+Math.pow(B,2)-2*A*B*Math.cos(Math.toRadians(kakudo))) Math.sqrt Math Math.pow(A,2)+Math.pow(B,2)-2*A*B*Math.cos(Math.toRadians(kakudo)) Math.pow(A,2)+Math.pow(B,2) Math.pow(A,2) Math.pow Math A 2 Math.pow(B,2) Math.pow Math B 2 2*A*B*Math.cos(Math.toRadians(kakudo)) B 2*A*B*Math.cos(Math.toRadians(kakudo)) 2 A B Math.cos(Math.toRadians(kakudo)) Math.cos Math Math.toRadians(kakudo) Math.toRadians Math kakudo String[] args args
import java.util.Scanner;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.HashSet;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    Double A=sc.nextDouble();
    Double B=sc.nextDouble();
    Double H=sc.nextDouble();
    Double M=sc.nextDouble();
    Double kakudo=Math.abs(H*30+30*(M/60)-M*6);
    if(kakudo>360-kakudo){
      kakudo=360-kakudo;
    }


    System.out.println(Math.sqrt(Math.pow(A,2)+Math.pow(B,2)-2*A*B*Math.cos(Math.toRadians(kakudo))));

  }
}
