

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


public class Main {
    public static void main(String[] args){
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            String[] inputs = br.readLine().split(" ");
            double hour = Double.parseDouble(inputs[0]);
            double minutes = Double.parseDouble(inputs[1]);
            double hour_jiaodu = Math.toRadians(Double.parseDouble(inputs[2])/12*360+30*Double.parseDouble(inputs[3])/60);
            double minute_jiaodu = Math.toRadians(Double.parseDouble(inputs[3])/60*360);
            double chajiao;
            double result;
            if(hour_jiaodu>minute_jiaodu){
                if((hour_jiaodu-minute_jiaodu)<=Math.PI){
                    result = Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(hour_jiaodu-minute_jiaodu));
                }
                else {
                    result=Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(2*Math.PI-(hour_jiaodu-minute_jiaodu)));
                }
            }
            else {
                if(minute_jiaodu-hour_jiaodu<=Math.PI){
                    result=Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(minute_jiaodu-hour_jiaodu));;
                }
                else {
                    result=Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(2*Math.PI-(minute_jiaodu-hour_jiaodu)));
                }
            }
            System.out.print(result);
        }catch (IOException e){
            e.printStackTrace();
        }
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
    public static void main(String[] args){
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            String[] inputs = br.readLine().split(" ");
            double hour = Double.parseDouble(inputs[0]);
            double minutes = Double.parseDouble(inputs[1]);
            double hour_jiaodu = Math.toRadians(Double.parseDouble(inputs[2])/12*360+30*Double.parseDouble(inputs[3])/60);
            double minute_jiaodu = Math.toRadians(Double.parseDouble(inputs[3])/60*360);
            double chajiao;
            double result;
            if(hour_jiaodu>minute_jiaodu){
                if((hour_jiaodu-minute_jiaodu)<=Math.PI){
                    result = Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(hour_jiaodu-minute_jiaodu));
                }
                else {
                    result=Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(2*Math.PI-(hour_jiaodu-minute_jiaodu)));
                }
            }
            else {
                if(minute_jiaodu-hour_jiaodu<=Math.PI){
                    result=Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(minute_jiaodu-hour_jiaodu));;
                }
                else {
                    result=Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(2*Math.PI-(minute_jiaodu-hour_jiaodu)));
                }
            }
            System.out.print(result);
        }catch (IOException e){
            e.printStackTrace();
        }
    }
} Main public static void main(String[] args){
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            String[] inputs = br.readLine().split(" ");
            double hour = Double.parseDouble(inputs[0]);
            double minutes = Double.parseDouble(inputs[1]);
            double hour_jiaodu = Math.toRadians(Double.parseDouble(inputs[2])/12*360+30*Double.parseDouble(inputs[3])/60);
            double minute_jiaodu = Math.toRadians(Double.parseDouble(inputs[3])/60*360);
            double chajiao;
            double result;
            if(hour_jiaodu>minute_jiaodu){
                if((hour_jiaodu-minute_jiaodu)<=Math.PI){
                    result = Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(hour_jiaodu-minute_jiaodu));
                }
                else {
                    result=Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(2*Math.PI-(hour_jiaodu-minute_jiaodu)));
                }
            }
            else {
                if(minute_jiaodu-hour_jiaodu<=Math.PI){
                    result=Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(minute_jiaodu-hour_jiaodu));;
                }
                else {
                    result=Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(2*Math.PI-(minute_jiaodu-hour_jiaodu)));
                }
            }
            System.out.print(result);
        }catch (IOException e){
            e.printStackTrace();
        }
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            String[] inputs = br.readLine().split(" ");
            double hour = Double.parseDouble(inputs[0]);
            double minutes = Double.parseDouble(inputs[1]);
            double hour_jiaodu = Math.toRadians(Double.parseDouble(inputs[2])/12*360+30*Double.parseDouble(inputs[3])/60);
            double minute_jiaodu = Math.toRadians(Double.parseDouble(inputs[3])/60*360);
            double chajiao;
            double result;
            if(hour_jiaodu>minute_jiaodu){
                if((hour_jiaodu-minute_jiaodu)<=Math.PI){
                    result = Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(hour_jiaodu-minute_jiaodu));
                }
                else {
                    result=Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(2*Math.PI-(hour_jiaodu-minute_jiaodu)));
                }
            }
            else {
                if(minute_jiaodu-hour_jiaodu<=Math.PI){
                    result=Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(minute_jiaodu-hour_jiaodu));;
                }
                else {
                    result=Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(2*Math.PI-(minute_jiaodu-hour_jiaodu)));
                }
            }
            System.out.print(result);
        }catch (IOException e){
            e.printStackTrace();
        }
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) try {
            String[] inputs = br.readLine().split(" ");
            double hour = Double.parseDouble(inputs[0]);
            double minutes = Double.parseDouble(inputs[1]);
            double hour_jiaodu = Math.toRadians(Double.parseDouble(inputs[2])/12*360+30*Double.parseDouble(inputs[3])/60);
            double minute_jiaodu = Math.toRadians(Double.parseDouble(inputs[3])/60*360);
            double chajiao;
            double result;
            if(hour_jiaodu>minute_jiaodu){
                if((hour_jiaodu-minute_jiaodu)<=Math.PI){
                    result = Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(hour_jiaodu-minute_jiaodu));
                }
                else {
                    result=Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(2*Math.PI-(hour_jiaodu-minute_jiaodu)));
                }
            }
            else {
                if(minute_jiaodu-hour_jiaodu<=Math.PI){
                    result=Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(minute_jiaodu-hour_jiaodu));;
                }
                else {
                    result=Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(2*Math.PI-(minute_jiaodu-hour_jiaodu)));
                }
            }
            System.out.print(result);
        }catch (IOException e){
            e.printStackTrace();
        } catch (IOException e){
            e.printStackTrace();
        } IOException e {
            e.printStackTrace();
        } e.printStackTrace() e.printStackTrace e {
            String[] inputs = br.readLine().split(" ");
            double hour = Double.parseDouble(inputs[0]);
            double minutes = Double.parseDouble(inputs[1]);
            double hour_jiaodu = Math.toRadians(Double.parseDouble(inputs[2])/12*360+30*Double.parseDouble(inputs[3])/60);
            double minute_jiaodu = Math.toRadians(Double.parseDouble(inputs[3])/60*360);
            double chajiao;
            double result;
            if(hour_jiaodu>minute_jiaodu){
                if((hour_jiaodu-minute_jiaodu)<=Math.PI){
                    result = Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(hour_jiaodu-minute_jiaodu));
                }
                else {
                    result=Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(2*Math.PI-(hour_jiaodu-minute_jiaodu)));
                }
            }
            else {
                if(minute_jiaodu-hour_jiaodu<=Math.PI){
                    result=Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(minute_jiaodu-hour_jiaodu));;
                }
                else {
                    result=Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(2*Math.PI-(minute_jiaodu-hour_jiaodu)));
                }
            }
            System.out.print(result);
        } String[] inputs = br.readLine().split(" "); inputs br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " double hour = Double.parseDouble(inputs[0]); hour Double.parseDouble(inputs[0]) Double.parseDouble Double inputs[0] inputs 0 double minutes = Double.parseDouble(inputs[1]); minutes Double.parseDouble(inputs[1]) Double.parseDouble Double inputs[1] inputs 1 double hour_jiaodu = Math.toRadians(Double.parseDouble(inputs[2])/12*360+30*Double.parseDouble(inputs[3])/60); hour_jiaodu Math.toRadians(Double.parseDouble(inputs[2])/12*360+30*Double.parseDouble(inputs[3])/60) Math.toRadians Math Double.parseDouble(inputs[2])/12*360+30*Double.parseDouble(inputs[3])/60 Double.parseDouble(inputs[2])/12*360 Double.parseDouble(inputs[2])/12 Double.parseDouble(inputs[2]) Double.parseDouble Double inputs[2] inputs 2 12 360 30*Double.parseDouble(inputs[3])/60 30*Double.parseDouble(inputs[3]) 30 Double.parseDouble(inputs[3]) Double.parseDouble Double inputs[3] inputs 3 60 double minute_jiaodu = Math.toRadians(Double.parseDouble(inputs[3])/60*360); minute_jiaodu Math.toRadians(Double.parseDouble(inputs[3])/60*360) Math.toRadians Math Double.parseDouble(inputs[3])/60*360 Double.parseDouble(inputs[3])/60 Double.parseDouble(inputs[3]) Double.parseDouble Double inputs[3] inputs 3 60 360 double chajiao; chajiao double result; result if(hour_jiaodu>minute_jiaodu){
                if((hour_jiaodu-minute_jiaodu)<=Math.PI){
                    result = Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(hour_jiaodu-minute_jiaodu));
                }
                else {
                    result=Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(2*Math.PI-(hour_jiaodu-minute_jiaodu)));
                }
            }
            else {
                if(minute_jiaodu-hour_jiaodu<=Math.PI){
                    result=Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(minute_jiaodu-hour_jiaodu));;
                }
                else {
                    result=Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(2*Math.PI-(minute_jiaodu-hour_jiaodu)));
                }
            } hour_jiaodu>minute_jiaodu hour_jiaodu minute_jiaodu {
                if((hour_jiaodu-minute_jiaodu)<=Math.PI){
                    result = Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(hour_jiaodu-minute_jiaodu));
                }
                else {
                    result=Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(2*Math.PI-(hour_jiaodu-minute_jiaodu)));
                }
            } if((hour_jiaodu-minute_jiaodu)<=Math.PI){
                    result = Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(hour_jiaodu-minute_jiaodu));
                }
                else {
                    result=Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(2*Math.PI-(hour_jiaodu-minute_jiaodu)));
                } (hour_jiaodu-minute_jiaodu)<=Math.PI (hour_jiaodu-minute_jiaodu) hour_jiaodu minute_jiaodu Math.PI Math Math.PI {
                    result = Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(hour_jiaodu-minute_jiaodu));
                } result = Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(hour_jiaodu-minute_jiaodu)) result Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(hour_jiaodu-minute_jiaodu)) Math.sqrt Math hour*hour+minutes*minutes-2*hour*minutes*Math.cos(hour_jiaodu-minute_jiaodu) hour*hour+minutes*minutes hour*hour hour hour minutes*minutes minutes minutes 2*hour*minutes*Math.cos(hour_jiaodu-minute_jiaodu) minutes 2*hour*minutes*Math.cos(hour_jiaodu-minute_jiaodu) 2 hour minutes Math.cos(hour_jiaodu-minute_jiaodu) Math.cos Math hour_jiaodu-minute_jiaodu hour_jiaodu minute_jiaodu {
                    result=Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(2*Math.PI-(hour_jiaodu-minute_jiaodu)));
                } result=Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(2*Math.PI-(hour_jiaodu-minute_jiaodu))) result Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(2*Math.PI-(hour_jiaodu-minute_jiaodu))) Math.sqrt Math hour*hour+minutes*minutes-2*hour*minutes*Math.cos(2*Math.PI-(hour_jiaodu-minute_jiaodu)) hour*hour+minutes*minutes hour*hour hour hour minutes*minutes minutes minutes 2*hour*minutes*Math.cos(2*Math.PI-(hour_jiaodu-minute_jiaodu)) minutes 2*hour*minutes*Math.cos(2*Math.PI-(hour_jiaodu-minute_jiaodu)) 2 hour minutes Math.cos(2*Math.PI-(hour_jiaodu-minute_jiaodu)) Math.cos Math 2*Math.PI-(hour_jiaodu-minute_jiaodu) 2*Math.PI 2 Math.PI Math Math.PI (hour_jiaodu-minute_jiaodu) hour_jiaodu minute_jiaodu {
                if(minute_jiaodu-hour_jiaodu<=Math.PI){
                    result=Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(minute_jiaodu-hour_jiaodu));;
                }
                else {
                    result=Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(2*Math.PI-(minute_jiaodu-hour_jiaodu)));
                }
            } if(minute_jiaodu-hour_jiaodu<=Math.PI){
                    result=Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(minute_jiaodu-hour_jiaodu));;
                }
                else {
                    result=Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(2*Math.PI-(minute_jiaodu-hour_jiaodu)));
                } minute_jiaodu-hour_jiaodu<=Math.PI minute_jiaodu-hour_jiaodu minute_jiaodu hour_jiaodu Math.PI Math Math.PI {
                    result=Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(minute_jiaodu-hour_jiaodu));;
                } result=Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(minute_jiaodu-hour_jiaodu)) result Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(minute_jiaodu-hour_jiaodu)) Math.sqrt Math hour*hour+minutes*minutes-2*hour*minutes*Math.cos(minute_jiaodu-hour_jiaodu) hour*hour+minutes*minutes hour*hour hour hour minutes*minutes minutes minutes 2*hour*minutes*Math.cos(minute_jiaodu-hour_jiaodu) minutes 2*hour*minutes*Math.cos(minute_jiaodu-hour_jiaodu) 2 hour minutes Math.cos(minute_jiaodu-hour_jiaodu) Math.cos Math minute_jiaodu-hour_jiaodu minute_jiaodu hour_jiaodu {
                    result=Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(2*Math.PI-(minute_jiaodu-hour_jiaodu)));
                } result=Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(2*Math.PI-(minute_jiaodu-hour_jiaodu))) result Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(2*Math.PI-(minute_jiaodu-hour_jiaodu))) Math.sqrt Math hour*hour+minutes*minutes-2*hour*minutes*Math.cos(2*Math.PI-(minute_jiaodu-hour_jiaodu)) hour*hour+minutes*minutes hour*hour hour hour minutes*minutes minutes minutes 2*hour*minutes*Math.cos(2*Math.PI-(minute_jiaodu-hour_jiaodu)) minutes 2*hour*minutes*Math.cos(2*Math.PI-(minute_jiaodu-hour_jiaodu)) 2 hour minutes Math.cos(2*Math.PI-(minute_jiaodu-hour_jiaodu)) Math.cos Math 2*Math.PI-(minute_jiaodu-hour_jiaodu) 2*Math.PI 2 Math.PI Math Math.PI (minute_jiaodu-hour_jiaodu) minute_jiaodu hour_jiaodu System.out.print(result) System.out.print System.out System System.out result String[] args args public class Main {
    public static void main(String[] args){
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            String[] inputs = br.readLine().split(" ");
            double hour = Double.parseDouble(inputs[0]);
            double minutes = Double.parseDouble(inputs[1]);
            double hour_jiaodu = Math.toRadians(Double.parseDouble(inputs[2])/12*360+30*Double.parseDouble(inputs[3])/60);
            double minute_jiaodu = Math.toRadians(Double.parseDouble(inputs[3])/60*360);
            double chajiao;
            double result;
            if(hour_jiaodu>minute_jiaodu){
                if((hour_jiaodu-minute_jiaodu)<=Math.PI){
                    result = Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(hour_jiaodu-minute_jiaodu));
                }
                else {
                    result=Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(2*Math.PI-(hour_jiaodu-minute_jiaodu)));
                }
            }
            else {
                if(minute_jiaodu-hour_jiaodu<=Math.PI){
                    result=Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(minute_jiaodu-hour_jiaodu));;
                }
                else {
                    result=Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(2*Math.PI-(minute_jiaodu-hour_jiaodu)));
                }
            }
            System.out.print(result);
        }catch (IOException e){
            e.printStackTrace();
        }
    }
} public class Main {
    public static void main(String[] args){
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            String[] inputs = br.readLine().split(" ");
            double hour = Double.parseDouble(inputs[0]);
            double minutes = Double.parseDouble(inputs[1]);
            double hour_jiaodu = Math.toRadians(Double.parseDouble(inputs[2])/12*360+30*Double.parseDouble(inputs[3])/60);
            double minute_jiaodu = Math.toRadians(Double.parseDouble(inputs[3])/60*360);
            double chajiao;
            double result;
            if(hour_jiaodu>minute_jiaodu){
                if((hour_jiaodu-minute_jiaodu)<=Math.PI){
                    result = Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(hour_jiaodu-minute_jiaodu));
                }
                else {
                    result=Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(2*Math.PI-(hour_jiaodu-minute_jiaodu)));
                }
            }
            else {
                if(minute_jiaodu-hour_jiaodu<=Math.PI){
                    result=Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(minute_jiaodu-hour_jiaodu));;
                }
                else {
                    result=Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(2*Math.PI-(minute_jiaodu-hour_jiaodu)));
                }
            }
            System.out.print(result);
        }catch (IOException e){
            e.printStackTrace();
        }
    }
} Main


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


public class Main {
    public static void main(String[] args){
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            String[] inputs = br.readLine().split(" ");
            double hour = Double.parseDouble(inputs[0]);
            double minutes = Double.parseDouble(inputs[1]);
            double hour_jiaodu = Math.toRadians(Double.parseDouble(inputs[2])/12*360+30*Double.parseDouble(inputs[3])/60);
            double minute_jiaodu = Math.toRadians(Double.parseDouble(inputs[3])/60*360);
            double chajiao;
            double result;
            if(hour_jiaodu>minute_jiaodu){
                if((hour_jiaodu-minute_jiaodu)<=Math.PI){
                    result = Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(hour_jiaodu-minute_jiaodu));
                }
                else {
                    result=Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(2*Math.PI-(hour_jiaodu-minute_jiaodu)));
                }
            }
            else {
                if(minute_jiaodu-hour_jiaodu<=Math.PI){
                    result=Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(minute_jiaodu-hour_jiaodu));;
                }
                else {
                    result=Math.sqrt(hour*hour+minutes*minutes-2*hour*minutes*Math.cos(2*Math.PI-(minute_jiaodu-hour_jiaodu)));
                }
            }
            System.out.print(result);
        }catch (IOException e){
            e.printStackTrace();
        }
    }
}
