import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int a = Integer.parseInt(str[0]);
    int b = Integer.parseInt(str[1]);
    int h = Integer.parseInt(str[2]);
    int m = Integer.parseInt(str[3]);
    double hour = (h*30)+(m*0.5);
    double min = m*6;
    double anglediff = Math.abs(hour-min);
    double ans = 0;
    
    double sqrt = Math.pow(a,2)+Math.pow(b,2)-2*a*b*Math.cos(Math.toRadians(anglediff));
    System.out.println(Math.sqrt(sqrt));
  }
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.IOException; IOException java.io public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int a = Integer.parseInt(str[0]);
    int b = Integer.parseInt(str[1]);
    int h = Integer.parseInt(str[2]);
    int m = Integer.parseInt(str[3]);
    double hour = (h*30)+(m*0.5);
    double min = m*6;
    double anglediff = Math.abs(hour-min);
    double ans = 0;
    
    double sqrt = Math.pow(a,2)+Math.pow(b,2)-2*a*b*Math.cos(Math.toRadians(anglediff));
    System.out.println(Math.sqrt(sqrt));
  }
} Main public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int a = Integer.parseInt(str[0]);
    int b = Integer.parseInt(str[1]);
    int h = Integer.parseInt(str[2]);
    int m = Integer.parseInt(str[3]);
    double hour = (h*30)+(m*0.5);
    double min = m*6;
    double anglediff = Math.abs(hour-min);
    double ans = 0;
    
    double sqrt = Math.pow(a,2)+Math.pow(b,2)-2*a*b*Math.cos(Math.toRadians(anglediff));
    System.out.println(Math.sqrt(sqrt));
  } main {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int a = Integer.parseInt(str[0]);
    int b = Integer.parseInt(str[1]);
    int h = Integer.parseInt(str[2]);
    int m = Integer.parseInt(str[3]);
    double hour = (h*30)+(m*0.5);
    double min = m*6;
    double anglediff = Math.abs(hour-min);
    double ans = 0;
    
    double sqrt = Math.pow(a,2)+Math.pow(b,2)-2*a*b*Math.cos(Math.toRadians(anglediff));
    System.out.println(Math.sqrt(sqrt));
  } BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); in new BufferedReader(new InputStreamReader(System.in)) String[] str = in.readLine().split(" "); str in.readLine().split(" ") in.readLine().split in.readLine() in.readLine in " " int a = Integer.parseInt(str[0]); a Integer.parseInt(str[0]) Integer.parseInt Integer str[0] str 0 int b = Integer.parseInt(str[1]); b Integer.parseInt(str[1]) Integer.parseInt Integer str[1] str 1 int h = Integer.parseInt(str[2]); h Integer.parseInt(str[2]) Integer.parseInt Integer str[2] str 2 int m = Integer.parseInt(str[3]); m Integer.parseInt(str[3]) Integer.parseInt Integer str[3] str 3 double hour = (h*30)+(m*0.5); hour (h*30)+(m*0.5) (h*30) h 30 (m*0.5) m 0.5 double min = m*6; min m*6 m 6 double anglediff = Math.abs(hour-min); anglediff Math.abs(hour-min) Math.abs Math hour-min hour min double ans = 0; ans 0 double sqrt = Math.pow(a,2)+Math.pow(b,2)-2*a*b*Math.cos(Math.toRadians(anglediff)); sqrt Math.pow(a,2)+Math.pow(b,2)-2*a*b*Math.cos(Math.toRadians(anglediff)) 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(anglediff)) b 2*a*b*Math.cos(Math.toRadians(anglediff)) 2 a b Math.cos(Math.toRadians(anglediff)) Math.cos Math Math.toRadians(anglediff) Math.toRadians Math anglediff System.out.println(Math.sqrt(sqrt)) System.out.println System.out System System.out Math.sqrt(sqrt) Math.sqrt Math sqrt String[] args args public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int a = Integer.parseInt(str[0]);
    int b = Integer.parseInt(str[1]);
    int h = Integer.parseInt(str[2]);
    int m = Integer.parseInt(str[3]);
    double hour = (h*30)+(m*0.5);
    double min = m*6;
    double anglediff = Math.abs(hour-min);
    double ans = 0;
    
    double sqrt = Math.pow(a,2)+Math.pow(b,2)-2*a*b*Math.cos(Math.toRadians(anglediff));
    System.out.println(Math.sqrt(sqrt));
  }
} public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int a = Integer.parseInt(str[0]);
    int b = Integer.parseInt(str[1]);
    int h = Integer.parseInt(str[2]);
    int m = Integer.parseInt(str[3]);
    double hour = (h*30)+(m*0.5);
    double min = m*6;
    double anglediff = Math.abs(hour-min);
    double ans = 0;
    
    double sqrt = Math.pow(a,2)+Math.pow(b,2)-2*a*b*Math.cos(Math.toRadians(anglediff));
    System.out.println(Math.sqrt(sqrt));
  }
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int a = Integer.parseInt(str[0]);
    int b = Integer.parseInt(str[1]);
    int h = Integer.parseInt(str[2]);
    int m = Integer.parseInt(str[3]);
    double hour = (h*30)+(m*0.5);
    double min = m*6;
    double anglediff = Math.abs(hour-min);
    double ans = 0;
    
    double sqrt = Math.pow(a,2)+Math.pow(b,2)-2*a*b*Math.cos(Math.toRadians(anglediff));
    System.out.println(Math.sqrt(sqrt));
  }
}