import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.StringTokenizer;

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

        double A = Double.parseDouble(st.nextToken());
        double B = Double.parseDouble(st.nextToken());
        double H = Double.parseDouble(st.nextToken());
        double M = Double.parseDouble(st.nextToken());
        
        double angle_H = (60 * H + M) / 720 * 360;
        double angle_M = M /60 * 360;

        double A_x = A * Math.cos(Math.toRadians(angle_H));
        double A_y = A * Math.sin(Math.toRadians(angle_H));

        double B_x = B * Math.cos(Math.toRadians(angle_M));
        double B_y = B * Math.sin(Math.toRadians(angle_M));

        double ans = Math.sqrt(Math.pow((A_x - B_x),2) + Math.pow((A_y - B_y),2));
       
        pw.println(ans);
        br.close();
        pw.close();
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.PrintWriter; PrintWriter java.io import java.util.StringTokenizer; StringTokenizer java.util public class Main {
    
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new java.io.InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(br.readLine());

        double A = Double.parseDouble(st.nextToken());
        double B = Double.parseDouble(st.nextToken());
        double H = Double.parseDouble(st.nextToken());
        double M = Double.parseDouble(st.nextToken());
        
        double angle_H = (60 * H + M) / 720 * 360;
        double angle_M = M /60 * 360;

        double A_x = A * Math.cos(Math.toRadians(angle_H));
        double A_y = A * Math.sin(Math.toRadians(angle_H));

        double B_x = B * Math.cos(Math.toRadians(angle_M));
        double B_y = B * Math.sin(Math.toRadians(angle_M));

        double ans = Math.sqrt(Math.pow((A_x - B_x),2) + Math.pow((A_y - B_y),2));
       
        pw.println(ans);
        br.close();
        pw.close();
    }
} Main public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new java.io.InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(br.readLine());

        double A = Double.parseDouble(st.nextToken());
        double B = Double.parseDouble(st.nextToken());
        double H = Double.parseDouble(st.nextToken());
        double M = Double.parseDouble(st.nextToken());
        
        double angle_H = (60 * H + M) / 720 * 360;
        double angle_M = M /60 * 360;

        double A_x = A * Math.cos(Math.toRadians(angle_H));
        double A_y = A * Math.sin(Math.toRadians(angle_H));

        double B_x = B * Math.cos(Math.toRadians(angle_M));
        double B_y = B * Math.sin(Math.toRadians(angle_M));

        double ans = Math.sqrt(Math.pow((A_x - B_x),2) + Math.pow((A_y - B_y),2));
       
        pw.println(ans);
        br.close();
        pw.close();
    } main {
        BufferedReader br = new BufferedReader(new java.io.InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(br.readLine());

        double A = Double.parseDouble(st.nextToken());
        double B = Double.parseDouble(st.nextToken());
        double H = Double.parseDouble(st.nextToken());
        double M = Double.parseDouble(st.nextToken());
        
        double angle_H = (60 * H + M) / 720 * 360;
        double angle_M = M /60 * 360;

        double A_x = A * Math.cos(Math.toRadians(angle_H));
        double A_y = A * Math.sin(Math.toRadians(angle_H));

        double B_x = B * Math.cos(Math.toRadians(angle_M));
        double B_y = B * Math.sin(Math.toRadians(angle_M));

        double ans = Math.sqrt(Math.pow((A_x - B_x),2) + Math.pow((A_y - B_y),2));
       
        pw.println(ans);
        br.close();
        pw.close();
    } BufferedReader br = new BufferedReader(new java.io.InputStreamReader(System.in)); br new BufferedReader(new java.io.InputStreamReader(System.in)) PrintWriter pw = new PrintWriter(System.out); pw new PrintWriter(System.out) StringTokenizer st = new StringTokenizer(br.readLine()); st new StringTokenizer(br.readLine()) double A = Double.parseDouble(st.nextToken()); A Double.parseDouble(st.nextToken()) Double.parseDouble Double st.nextToken() st.nextToken st double B = Double.parseDouble(st.nextToken()); B Double.parseDouble(st.nextToken()) Double.parseDouble Double st.nextToken() st.nextToken st double H = Double.parseDouble(st.nextToken()); H Double.parseDouble(st.nextToken()) Double.parseDouble Double st.nextToken() st.nextToken st double M = Double.parseDouble(st.nextToken()); M Double.parseDouble(st.nextToken()) Double.parseDouble Double st.nextToken() st.nextToken st double angle_H = (60 * H + M) / 720 * 360; angle_H (60 * H + M) / 720 * 360 (60 * H + M) / 720 (60 * H + M) 60 * H 60 H M 720 360 double angle_M = M /60 * 360; angle_M M /60 * 360 M /60 M 60 360 double A_x = A * Math.cos(Math.toRadians(angle_H)); A_x A * Math.cos(Math.toRadians(angle_H)) A Math.cos(Math.toRadians(angle_H)) Math.cos Math Math.toRadians(angle_H) Math.toRadians Math angle_H double A_y = A * Math.sin(Math.toRadians(angle_H)); A_y A * Math.sin(Math.toRadians(angle_H)) A Math.sin(Math.toRadians(angle_H)) Math.sin Math Math.toRadians(angle_H) Math.toRadians Math angle_H double B_x = B * Math.cos(Math.toRadians(angle_M)); B_x B * Math.cos(Math.toRadians(angle_M)) B Math.cos(Math.toRadians(angle_M)) Math.cos Math Math.toRadians(angle_M) Math.toRadians Math angle_M double B_y = B * Math.sin(Math.toRadians(angle_M)); B_y B * Math.sin(Math.toRadians(angle_M)) B Math.sin(Math.toRadians(angle_M)) Math.sin Math Math.toRadians(angle_M) Math.toRadians Math angle_M double ans = Math.sqrt(Math.pow((A_x - B_x),2) + Math.pow((A_y - B_y),2)); ans Math.sqrt(Math.pow((A_x - B_x),2) + Math.pow((A_y - B_y),2)) Math.sqrt Math Math.pow((A_x - B_x),2) + Math.pow((A_y - B_y),2) Math.pow((A_x - B_x),2) Math.pow Math (A_x - B_x) A_x B_x 2 Math.pow((A_y - B_y),2) Math.pow Math (A_y - B_y) A_y B_y 2 pw.println(ans) pw.println pw ans br.close() br.close br pw.close() pw.close pw String[] args args public class Main {
    
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new java.io.InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(br.readLine());

        double A = Double.parseDouble(st.nextToken());
        double B = Double.parseDouble(st.nextToken());
        double H = Double.parseDouble(st.nextToken());
        double M = Double.parseDouble(st.nextToken());
        
        double angle_H = (60 * H + M) / 720 * 360;
        double angle_M = M /60 * 360;

        double A_x = A * Math.cos(Math.toRadians(angle_H));
        double A_y = A * Math.sin(Math.toRadians(angle_H));

        double B_x = B * Math.cos(Math.toRadians(angle_M));
        double B_y = B * Math.sin(Math.toRadians(angle_M));

        double ans = Math.sqrt(Math.pow((A_x - B_x),2) + Math.pow((A_y - B_y),2));
       
        pw.println(ans);
        br.close();
        pw.close();
    }
} public class Main {
    
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new java.io.InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(br.readLine());

        double A = Double.parseDouble(st.nextToken());
        double B = Double.parseDouble(st.nextToken());
        double H = Double.parseDouble(st.nextToken());
        double M = Double.parseDouble(st.nextToken());
        
        double angle_H = (60 * H + M) / 720 * 360;
        double angle_M = M /60 * 360;

        double A_x = A * Math.cos(Math.toRadians(angle_H));
        double A_y = A * Math.sin(Math.toRadians(angle_H));

        double B_x = B * Math.cos(Math.toRadians(angle_M));
        double B_y = B * Math.sin(Math.toRadians(angle_M));

        double ans = Math.sqrt(Math.pow((A_x - B_x),2) + Math.pow((A_y - B_y),2));
       
        pw.println(ans);
        br.close();
        pw.close();
    }
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.StringTokenizer;

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

        double A = Double.parseDouble(st.nextToken());
        double B = Double.parseDouble(st.nextToken());
        double H = Double.parseDouble(st.nextToken());
        double M = Double.parseDouble(st.nextToken());
        
        double angle_H = (60 * H + M) / 720 * 360;
        double angle_M = M /60 * 360;

        double A_x = A * Math.cos(Math.toRadians(angle_H));
        double A_y = A * Math.sin(Math.toRadians(angle_H));

        double B_x = B * Math.cos(Math.toRadians(angle_M));
        double B_y = B * Math.sin(Math.toRadians(angle_M));

        double ans = Math.sqrt(Math.pow((A_x - B_x),2) + Math.pow((A_y - B_y),2));
       
        pw.println(ans);
        br.close();
        pw.close();
    }
}