import java.util.*;
import java.io.*;

class Main{
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st  = new StringTokenizer(br.readLine());

        int A = Integer.parseInt(st.nextToken());
        int B = Integer.parseInt(st.nextToken());
        int H = Integer.parseInt(st.nextToken());
        int M = Integer.parseInt(st.nextToken());

        int mins = 60*H+M;

        double M_angle = M*6;
        double H_angle = mins*0.5;

        double x1 = A*Math.cos(Math.toRadians(H_angle));
        double y1 = A*Math.sin(Math.toRadians(H_angle));
        double x2 = B*Math.cos(Math.toRadians(M_angle));
        double y2 = B*Math.sin(Math.toRadians(M_angle));

        System.out.println(Math.sqrt((x2-x1)*(x2-x1)  + (y2-y1)*(y2-y1)));



    }

} import java.util.*; util.* java import java.io.*; io.* java class Main{
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st  = new StringTokenizer(br.readLine());

        int A = Integer.parseInt(st.nextToken());
        int B = Integer.parseInt(st.nextToken());
        int H = Integer.parseInt(st.nextToken());
        int M = Integer.parseInt(st.nextToken());

        int mins = 60*H+M;

        double M_angle = M*6;
        double H_angle = mins*0.5;

        double x1 = A*Math.cos(Math.toRadians(H_angle));
        double y1 = A*Math.sin(Math.toRadians(H_angle));
        double x2 = B*Math.cos(Math.toRadians(M_angle));
        double y2 = B*Math.sin(Math.toRadians(M_angle));

        System.out.println(Math.sqrt((x2-x1)*(x2-x1)  + (y2-y1)*(y2-y1)));



    }

} Main public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st  = new StringTokenizer(br.readLine());

        int A = Integer.parseInt(st.nextToken());
        int B = Integer.parseInt(st.nextToken());
        int H = Integer.parseInt(st.nextToken());
        int M = Integer.parseInt(st.nextToken());

        int mins = 60*H+M;

        double M_angle = M*6;
        double H_angle = mins*0.5;

        double x1 = A*Math.cos(Math.toRadians(H_angle));
        double y1 = A*Math.sin(Math.toRadians(H_angle));
        double x2 = B*Math.cos(Math.toRadians(M_angle));
        double y2 = B*Math.sin(Math.toRadians(M_angle));

        System.out.println(Math.sqrt((x2-x1)*(x2-x1)  + (y2-y1)*(y2-y1)));



    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st  = new StringTokenizer(br.readLine());

        int A = Integer.parseInt(st.nextToken());
        int B = Integer.parseInt(st.nextToken());
        int H = Integer.parseInt(st.nextToken());
        int M = Integer.parseInt(st.nextToken());

        int mins = 60*H+M;

        double M_angle = M*6;
        double H_angle = mins*0.5;

        double x1 = A*Math.cos(Math.toRadians(H_angle));
        double y1 = A*Math.sin(Math.toRadians(H_angle));
        double x2 = B*Math.cos(Math.toRadians(M_angle));
        double y2 = B*Math.sin(Math.toRadians(M_angle));

        System.out.println(Math.sqrt((x2-x1)*(x2-x1)  + (y2-y1)*(y2-y1)));



    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) StringTokenizer st  = new StringTokenizer(br.readLine()); st new StringTokenizer(br.readLine()) int A = Integer.parseInt(st.nextToken()); A Integer.parseInt(st.nextToken()) Integer.parseInt Integer st.nextToken() st.nextToken st int B = Integer.parseInt(st.nextToken()); B Integer.parseInt(st.nextToken()) Integer.parseInt Integer st.nextToken() st.nextToken st int H = Integer.parseInt(st.nextToken()); H Integer.parseInt(st.nextToken()) Integer.parseInt Integer st.nextToken() st.nextToken st int M = Integer.parseInt(st.nextToken()); M Integer.parseInt(st.nextToken()) Integer.parseInt Integer st.nextToken() st.nextToken st int mins = 60*H+M; mins 60*H+M 60*H 60 H M double M_angle = M*6; M_angle M*6 M 6 double H_angle = mins*0.5; H_angle mins*0.5 mins 0.5 double x1 = A*Math.cos(Math.toRadians(H_angle)); x1 A*Math.cos(Math.toRadians(H_angle)) A Math.cos(Math.toRadians(H_angle)) Math.cos Math Math.toRadians(H_angle) Math.toRadians Math H_angle double y1 = A*Math.sin(Math.toRadians(H_angle)); y1 A*Math.sin(Math.toRadians(H_angle)) A Math.sin(Math.toRadians(H_angle)) Math.sin Math Math.toRadians(H_angle) Math.toRadians Math H_angle double x2 = B*Math.cos(Math.toRadians(M_angle)); x2 B*Math.cos(Math.toRadians(M_angle)) B Math.cos(Math.toRadians(M_angle)) Math.cos Math Math.toRadians(M_angle) Math.toRadians Math M_angle double y2 = B*Math.sin(Math.toRadians(M_angle)); y2 B*Math.sin(Math.toRadians(M_angle)) B Math.sin(Math.toRadians(M_angle)) Math.sin Math Math.toRadians(M_angle) Math.toRadians Math M_angle System.out.println(Math.sqrt((x2-x1)*(x2-x1)  + (y2-y1)*(y2-y1))) System.out.println System.out System System.out Math.sqrt((x2-x1)*(x2-x1)  + (y2-y1)*(y2-y1)) Math.sqrt Math (x2-x1)*(x2-x1)  + (y2-y1)*(y2-y1) (x2-x1)*(x2-x1) (x2-x1) x2 x1 (x2-x1) x2 x1 (y2-y1)*(y2-y1) (y2-y1) y2 y1 (y2-y1) y2 y1 String[] args args
import java.util.*;
import java.io.*;

class Main{
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st  = new StringTokenizer(br.readLine());

        int A = Integer.parseInt(st.nextToken());
        int B = Integer.parseInt(st.nextToken());
        int H = Integer.parseInt(st.nextToken());
        int M = Integer.parseInt(st.nextToken());

        int mins = 60*H+M;

        double M_angle = M*6;
        double H_angle = mins*0.5;

        double x1 = A*Math.cos(Math.toRadians(H_angle));
        double y1 = A*Math.sin(Math.toRadians(H_angle));
        double x2 = B*Math.cos(Math.toRadians(M_angle));
        double y2 = B*Math.sin(Math.toRadians(M_angle));

        System.out.println(Math.sqrt((x2-x1)*(x2-x1)  + (y2-y1)*(y2-y1)));



    }

}