/* package codechef; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
public class Main{
   static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static PrintWriter pw = new PrintWriter(System.out);
    static StringTokenizer st;
    
    static String next()
        {
            while(st==null || !st.hasMoreElements()) 
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch(IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
  
    static double calcAngle(double h, double m) 
    { 
        // validate the input 
        if (h <0 || m < 0 || h >12 || m > 60) 
            System.out.println("Wrong input"); 
  
        if (h == 12) 
            h = 0; 
        if (m == 60)  
            m = 0; 
  
        // Calculate the angles moved by hour and minute hands 
        // with reference to 12:00 
        double hour_angle = (double)(0.5 * (h*60 + m)); 
        double minute_angle = (double)(6*m); 
  
        // Find the difference between two angles 
        double angle = (double)Math.abs(hour_angle - minute_angle); 
  
        // smaller angle of two possible angles 
        angle = (double)Math.min(360-angle, angle); 
  
        return angle; 
    } 
  
    // Function to find third side 
    static double third_side(double a,  
                    double b, double c) 
    { 
        double angle =(double) Math.cos((double)Math.toRadians(c));
          
        return (double)Math.sqrt((a * a) + 
            (b * b) - 2 * a * b * angle); 
} 
  public static void main (String[] args) throws java.lang.Exception
   {
	try{
	   
		  double a=Double.parseDouble(next());
		  double b=Double.parseDouble(next());
		  double h=Double.parseDouble(next());
		  double m=Double.parseDouble(next());
		  
		  double angle=calcAngle(h,m);
		  double side=third_side(a,b,angle);
		  System.out.printf("%.20f",side);
		      
		      
		    
	   }     
	catch(Exception e)
		 {}
	}
} import java.util.*; util.* java import java.lang.*; lang.* java import java.io.*; io.* java public class Main{
   static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static PrintWriter pw = new PrintWriter(System.out);
    static StringTokenizer st;
    
    static String next()
        {
            while(st==null || !st.hasMoreElements()) 
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch(IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
  
    static double calcAngle(double h, double m) 
    { 
        // validate the input 
        if (h <0 || m < 0 || h >12 || m > 60) 
            System.out.println("Wrong input"); 
  
        if (h == 12) 
            h = 0; 
        if (m == 60)  
            m = 0; 
  
        // Calculate the angles moved by hour and minute hands 
        // with reference to 12:00 
        double hour_angle = (double)(0.5 * (h*60 + m)); 
        double minute_angle = (double)(6*m); 
  
        // Find the difference between two angles 
        double angle = (double)Math.abs(hour_angle - minute_angle); 
  
        // smaller angle of two possible angles 
        angle = (double)Math.min(360-angle, angle); 
  
        return angle; 
    } 
  
    // Function to find third side 
    static double third_side(double a,  
                    double b, double c) 
    { 
        double angle =(double) Math.cos((double)Math.toRadians(c));
          
        return (double)Math.sqrt((a * a) + 
            (b * b) - 2 * a * b * angle); 
} 
  public static void main (String[] args) throws java.lang.Exception
   {
	try{
	   
		  double a=Double.parseDouble(next());
		  double b=Double.parseDouble(next());
		  double h=Double.parseDouble(next());
		  double m=Double.parseDouble(next());
		  
		  double angle=calcAngle(h,m);
		  double side=third_side(a,b,angle);
		  System.out.printf("%.20f",side);
		      
		      
		    
	   }     
	catch(Exception e)
		 {}
	}
} Main static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) static PrintWriter pw = new PrintWriter(System.out); pw new PrintWriter(System.out) static StringTokenizer st; st static String next()
        {
            while(st==null || !st.hasMoreElements()) 
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch(IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        } next {
            while(st==null || !st.hasMoreElements()) 
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch(IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        } while(st==null || !st.hasMoreElements()) 
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch(IOException e)
                {
                    e.printStackTrace();
                }
            } st==null || !st.hasMoreElements() st==null st null !st.hasMoreElements() st.hasMoreElements() st.hasMoreElements st {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch(IOException e)
                {
                    e.printStackTrace();
                }
            } try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch(IOException e)
                {
                    e.printStackTrace();
                } catch(IOException e)
                {
                    e.printStackTrace();
                } IOException e {
                    e.printStackTrace();
                } e.printStackTrace() e.printStackTrace e {
                    st = new StringTokenizer(br.readLine());
                } st = new StringTokenizer(br.readLine()) st new StringTokenizer(br.readLine()) return st.nextToken(); st.nextToken() st.nextToken st static double calcAngle(double h, double m) 
    { 
        // validate the input 
        if (h <0 || m < 0 || h >12 || m > 60) 
            System.out.println("Wrong input"); 
  
        if (h == 12) 
            h = 0; 
        if (m == 60)  
            m = 0; 
  
        // Calculate the angles moved by hour and minute hands 
        // with reference to 12:00 
        double hour_angle = (double)(0.5 * (h*60 + m)); 
        double minute_angle = (double)(6*m); 
  
        // Find the difference between two angles 
        double angle = (double)Math.abs(hour_angle - minute_angle); 
  
        // smaller angle of two possible angles 
        angle = (double)Math.min(360-angle, angle); 
  
        return angle; 
    } calcAngle { 
        // validate the input 
        if (h <0 || m < 0 || h >12 || m > 60) 
            System.out.println("Wrong input"); 
  
        if (h == 12) 
            h = 0; 
        if (m == 60)  
            m = 0; 
  
        // Calculate the angles moved by hour and minute hands 
        // with reference to 12:00 
        double hour_angle = (double)(0.5 * (h*60 + m)); 
        double minute_angle = (double)(6*m); 
  
        // Find the difference between two angles 
        double angle = (double)Math.abs(hour_angle - minute_angle); 
  
        // smaller angle of two possible angles 
        angle = (double)Math.min(360-angle, angle); 
  
        return angle; 
    } if (h <0 || m < 0 || h >12 || m > 60) 
            System.out.println("Wrong input"); h <0 || m < 0 || h >12 || m > 60 h >12 h <0 || m < 0 || h >12 || m > 60 h <0 h 0 m < 0 m 0 h >12 h 12 m > 60 m 60 System.out.println("Wrong input") System.out.println System.out System System.out "Wrong input" if (h == 12) 
            h = 0; h == 12 h 12 h = 0 h 0 if (m == 60)  
            m = 0; m == 60 m 60 m = 0 m 0 double hour_angle = (double)(0.5 * (h*60 + m)); hour_angle (double)(0.5 * (h*60 + m)) 0.5 (h*60 + m) h*60 h 60 m double minute_angle = (double)(6*m); minute_angle (double)(6*m) 6 m double angle = (double)Math.abs(hour_angle - minute_angle); angle (double)Math.abs(hour_angle - minute_angle) Math.abs Math hour_angle - minute_angle hour_angle minute_angle angle = (double)Math.min(360-angle, angle) angle (double)Math.min(360-angle, angle) Math.min Math 360-angle 360 angle angle return angle; angle double h h double m m // Function to find third side 
    static double third_side(double a,  
                    double b, double c) 
    { 
        double angle =(double) Math.cos((double)Math.toRadians(c));
          
        return (double)Math.sqrt((a * a) + 
            (b * b) - 2 * a * b * angle); 
} third_side { 
        double angle =(double) Math.cos((double)Math.toRadians(c));
          
        return (double)Math.sqrt((a * a) + 
            (b * b) - 2 * a * b * angle); 
} double angle =(double) Math.cos((double)Math.toRadians(c)); angle (double) Math.cos((double)Math.toRadians(c)) Math.cos Math (double)Math.toRadians(c) Math.toRadians Math c return (double)Math.sqrt((a * a) + 
            (b * b) - 2 * a * b * angle); (double)Math.sqrt((a * a) + 
            (b * b) - 2 * a * b * angle) Math.sqrt Math (a * a) + 
            (b * b) - 2 * a * b * angle (a * a) + 
            (b * b) (a * a) a a (b * b) b b 2 * a * b * angle b 2 * a * b * angle 2 a b angle double a a double b b double c c public static void main (String[] args) throws java.lang.Exception
   {
	try{
	   
		  double a=Double.parseDouble(next());
		  double b=Double.parseDouble(next());
		  double h=Double.parseDouble(next());
		  double m=Double.parseDouble(next());
		  
		  double angle=calcAngle(h,m);
		  double side=third_side(a,b,angle);
		  System.out.printf("%.20f",side);
		      
		      
		    
	   }     
	catch(Exception e)
		 {}
	} main {
	try{
	   
		  double a=Double.parseDouble(next());
		  double b=Double.parseDouble(next());
		  double h=Double.parseDouble(next());
		  double m=Double.parseDouble(next());
		  
		  double angle=calcAngle(h,m);
		  double side=third_side(a,b,angle);
		  System.out.printf("%.20f",side);
		      
		      
		    
	   }     
	catch(Exception e)
		 {}
	} try{
	   
		  double a=Double.parseDouble(next());
		  double b=Double.parseDouble(next());
		  double h=Double.parseDouble(next());
		  double m=Double.parseDouble(next());
		  
		  double angle=calcAngle(h,m);
		  double side=third_side(a,b,angle);
		  System.out.printf("%.20f",side);
		      
		      
		    
	   }     
	catch(Exception e)
		 {} catch(Exception e)
		 {} Exception e {} {
	   
		  double a=Double.parseDouble(next());
		  double b=Double.parseDouble(next());
		  double h=Double.parseDouble(next());
		  double m=Double.parseDouble(next());
		  
		  double angle=calcAngle(h,m);
		  double side=third_side(a,b,angle);
		  System.out.printf("%.20f",side);
		      
		      
		    
	   } double a=Double.parseDouble(next()); a Double.parseDouble(next()) Double.parseDouble Double next() next double b=Double.parseDouble(next()); b Double.parseDouble(next()) Double.parseDouble Double next() next double h=Double.parseDouble(next()); h Double.parseDouble(next()) Double.parseDouble Double next() next double m=Double.parseDouble(next()); m Double.parseDouble(next()) Double.parseDouble Double next() next double angle=calcAngle(h,m); angle calcAngle(h,m) calcAngle h m double side=third_side(a,b,angle); side third_side(a,b,angle) third_side a b angle System.out.printf("%.20f",side) System.out.printf System.out System System.out "%.20f" side String[] args args public class Main{
   static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static PrintWriter pw = new PrintWriter(System.out);
    static StringTokenizer st;
    
    static String next()
        {
            while(st==null || !st.hasMoreElements()) 
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch(IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
  
    static double calcAngle(double h, double m) 
    { 
        // validate the input 
        if (h <0 || m < 0 || h >12 || m > 60) 
            System.out.println("Wrong input"); 
  
        if (h == 12) 
            h = 0; 
        if (m == 60)  
            m = 0; 
  
        // Calculate the angles moved by hour and minute hands 
        // with reference to 12:00 
        double hour_angle = (double)(0.5 * (h*60 + m)); 
        double minute_angle = (double)(6*m); 
  
        // Find the difference between two angles 
        double angle = (double)Math.abs(hour_angle - minute_angle); 
  
        // smaller angle of two possible angles 
        angle = (double)Math.min(360-angle, angle); 
  
        return angle; 
    } 
  
    // Function to find third side 
    static double third_side(double a,  
                    double b, double c) 
    { 
        double angle =(double) Math.cos((double)Math.toRadians(c));
          
        return (double)Math.sqrt((a * a) + 
            (b * b) - 2 * a * b * angle); 
} 
  public static void main (String[] args) throws java.lang.Exception
   {
	try{
	   
		  double a=Double.parseDouble(next());
		  double b=Double.parseDouble(next());
		  double h=Double.parseDouble(next());
		  double m=Double.parseDouble(next());
		  
		  double angle=calcAngle(h,m);
		  double side=third_side(a,b,angle);
		  System.out.printf("%.20f",side);
		      
		      
		    
	   }     
	catch(Exception e)
		 {}
	}
} public class Main{
   static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static PrintWriter pw = new PrintWriter(System.out);
    static StringTokenizer st;
    
    static String next()
        {
            while(st==null || !st.hasMoreElements()) 
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch(IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
  
    static double calcAngle(double h, double m) 
    { 
        // validate the input 
        if (h <0 || m < 0 || h >12 || m > 60) 
            System.out.println("Wrong input"); 
  
        if (h == 12) 
            h = 0; 
        if (m == 60)  
            m = 0; 
  
        // Calculate the angles moved by hour and minute hands 
        // with reference to 12:00 
        double hour_angle = (double)(0.5 * (h*60 + m)); 
        double minute_angle = (double)(6*m); 
  
        // Find the difference between two angles 
        double angle = (double)Math.abs(hour_angle - minute_angle); 
  
        // smaller angle of two possible angles 
        angle = (double)Math.min(360-angle, angle); 
  
        return angle; 
    } 
  
    // Function to find third side 
    static double third_side(double a,  
                    double b, double c) 
    { 
        double angle =(double) Math.cos((double)Math.toRadians(c));
          
        return (double)Math.sqrt((a * a) + 
            (b * b) - 2 * a * b * angle); 
} 
  public static void main (String[] args) throws java.lang.Exception
   {
	try{
	   
		  double a=Double.parseDouble(next());
		  double b=Double.parseDouble(next());
		  double h=Double.parseDouble(next());
		  double m=Double.parseDouble(next());
		  
		  double angle=calcAngle(h,m);
		  double side=third_side(a,b,angle);
		  System.out.printf("%.20f",side);
		      
		      
		    
	   }     
	catch(Exception e)
		 {}
	}
} Main
/* package codechef; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
public class Main{
   static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static PrintWriter pw = new PrintWriter(System.out);
    static StringTokenizer st;
    
    static String next()
        {
            while(st==null || !st.hasMoreElements()) 
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch(IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
  
    static double calcAngle(double h, double m) 
    { 
        // validate the input 
        if (h <0 || m < 0 || h >12 || m > 60) 
            System.out.println("Wrong input"); 
  
        if (h == 12) 
            h = 0; 
        if (m == 60)  
            m = 0; 
  
        // Calculate the angles moved by hour and minute hands 
        // with reference to 12:00 
        double hour_angle = (double)(0.5 * (h*60 + m)); 
        double minute_angle = (double)(6*m); 
  
        // Find the difference between two angles 
        double angle = (double)Math.abs(hour_angle - minute_angle); 
  
        // smaller angle of two possible angles 
        angle = (double)Math.min(360-angle, angle); 
  
        return angle; 
    } 
  
    // Function to find third side 
    static double third_side(double a,  
                    double b, double c) 
    { 
        double angle =(double) Math.cos((double)Math.toRadians(c));
          
        return (double)Math.sqrt((a * a) + 
            (b * b) - 2 * a * b * angle); 
} 
  public static void main (String[] args) throws java.lang.Exception
   {
	try{
	   
		  double a=Double.parseDouble(next());
		  double b=Double.parseDouble(next());
		  double h=Double.parseDouble(next());
		  double m=Double.parseDouble(next());
		  
		  double angle=calcAngle(h,m);
		  double side=third_side(a,b,angle);
		  System.out.printf("%.20f",side);
		      
		      
		    
	   }     
	catch(Exception e)
		 {}
	}
}
