
import java.util.*;


 
public class Main {

    public static void main(String args[])  {
    	Scanner sc = new Scanner(System.in);
    	double shortA=sc.nextInt();
    	double longB =sc.nextInt();
    	double time=sc.nextInt();
    	double minute=sc.nextInt();
    	double all=360;
    	double ans=0.0;
        double timeMinute=60.0*time+minute;
        double shortaa=(timeMinute/720.0)*360;
        double longaa =minute*6;
        double angle=0.0;
        if(shortaa<longaa) {
        	angle=longaa-shortaa;
        }else {
        	angle=shortaa-longaa;
        } 

  
        if(angle==360.0) {
        	angle=0.0;
        }
        else if(angle>180.0) {
        	angle=360.0-angle;
        }
     
        double cos = Math.cos(Math.toRadians(angle));
         ans= Math.sqrt( Math.pow(shortA, 2)+Math.pow(longB, 2)-2.0*shortA*longB*cos);

  
        System.out.println(ans);


    }
} import java.util.*; util.* java public class Main {

    public static void main(String args[])  {
    	Scanner sc = new Scanner(System.in);
    	double shortA=sc.nextInt();
    	double longB =sc.nextInt();
    	double time=sc.nextInt();
    	double minute=sc.nextInt();
    	double all=360;
    	double ans=0.0;
        double timeMinute=60.0*time+minute;
        double shortaa=(timeMinute/720.0)*360;
        double longaa =minute*6;
        double angle=0.0;
        if(shortaa<longaa) {
        	angle=longaa-shortaa;
        }else {
        	angle=shortaa-longaa;
        } 

  
        if(angle==360.0) {
        	angle=0.0;
        }
        else if(angle>180.0) {
        	angle=360.0-angle;
        }
     
        double cos = Math.cos(Math.toRadians(angle));
         ans= Math.sqrt( Math.pow(shortA, 2)+Math.pow(longB, 2)-2.0*shortA*longB*cos);

  
        System.out.println(ans);


    }
} Main public static void main(String args[])  {
    	Scanner sc = new Scanner(System.in);
    	double shortA=sc.nextInt();
    	double longB =sc.nextInt();
    	double time=sc.nextInt();
    	double minute=sc.nextInt();
    	double all=360;
    	double ans=0.0;
        double timeMinute=60.0*time+minute;
        double shortaa=(timeMinute/720.0)*360;
        double longaa =minute*6;
        double angle=0.0;
        if(shortaa<longaa) {
        	angle=longaa-shortaa;
        }else {
        	angle=shortaa-longaa;
        } 

  
        if(angle==360.0) {
        	angle=0.0;
        }
        else if(angle>180.0) {
        	angle=360.0-angle;
        }
     
        double cos = Math.cos(Math.toRadians(angle));
         ans= Math.sqrt( Math.pow(shortA, 2)+Math.pow(longB, 2)-2.0*shortA*longB*cos);

  
        System.out.println(ans);


    } main {
    	Scanner sc = new Scanner(System.in);
    	double shortA=sc.nextInt();
    	double longB =sc.nextInt();
    	double time=sc.nextInt();
    	double minute=sc.nextInt();
    	double all=360;
    	double ans=0.0;
        double timeMinute=60.0*time+minute;
        double shortaa=(timeMinute/720.0)*360;
        double longaa =minute*6;
        double angle=0.0;
        if(shortaa<longaa) {
        	angle=longaa-shortaa;
        }else {
        	angle=shortaa-longaa;
        } 

  
        if(angle==360.0) {
        	angle=0.0;
        }
        else if(angle>180.0) {
        	angle=360.0-angle;
        }
     
        double cos = Math.cos(Math.toRadians(angle));
         ans= Math.sqrt( Math.pow(shortA, 2)+Math.pow(longB, 2)-2.0*shortA*longB*cos);

  
        System.out.println(ans);


    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) double shortA=sc.nextInt(); shortA sc.nextInt() sc.nextInt sc double longB =sc.nextInt(); longB sc.nextInt() sc.nextInt sc double time=sc.nextInt(); time sc.nextInt() sc.nextInt sc double minute=sc.nextInt(); minute sc.nextInt() sc.nextInt sc double all=360; all 360 double ans=0.0; ans 0.0 double timeMinute=60.0*time+minute; timeMinute 60.0*time+minute 60.0*time 60.0 time minute double shortaa=(timeMinute/720.0)*360; shortaa (timeMinute/720.0)*360 (timeMinute/720.0) timeMinute 720.0 360 double longaa =minute*6; longaa minute*6 minute 6 double angle=0.0; angle 0.0 if(shortaa<longaa) {
        	angle=longaa-shortaa;
        }else {
        	angle=shortaa-longaa;
        } shortaa<longaa shortaa longaa {
        	angle=longaa-shortaa;
        } angle=longaa-shortaa angle longaa-shortaa longaa shortaa {
        	angle=shortaa-longaa;
        } angle=shortaa-longaa angle shortaa-longaa shortaa longaa if(angle==360.0) {
        	angle=0.0;
        }
        else if(angle>180.0) {
        	angle=360.0-angle;
        } angle==360.0 angle 360.0 {
        	angle=0.0;
        } angle=0.0 angle 0.0 if(angle>180.0) {
        	angle=360.0-angle;
        } angle>180.0 angle 180.0 {
        	angle=360.0-angle;
        } angle=360.0-angle angle 360.0-angle 360.0 angle double cos = Math.cos(Math.toRadians(angle)); cos Math.cos(Math.toRadians(angle)) Math.cos Math Math.toRadians(angle) Math.toRadians Math angle ans= Math.sqrt( Math.pow(shortA, 2)+Math.pow(longB, 2)-2.0*shortA*longB*cos) ans Math.sqrt( Math.pow(shortA, 2)+Math.pow(longB, 2)-2.0*shortA*longB*cos) Math.sqrt Math Math.pow(shortA, 2)+Math.pow(longB, 2)-2.0*shortA*longB*cos Math.pow(shortA, 2)+Math.pow(longB, 2) Math.pow(shortA, 2) Math.pow Math shortA 2 Math.pow(longB, 2) Math.pow Math longB 2 2.0*shortA*longB*cos longB 2.0*shortA*longB*cos 2.0 shortA longB cos System.out.println(ans) System.out.println System.out System System.out ans String args[] args public class Main {

    public static void main(String args[])  {
    	Scanner sc = new Scanner(System.in);
    	double shortA=sc.nextInt();
    	double longB =sc.nextInt();
    	double time=sc.nextInt();
    	double minute=sc.nextInt();
    	double all=360;
    	double ans=0.0;
        double timeMinute=60.0*time+minute;
        double shortaa=(timeMinute/720.0)*360;
        double longaa =minute*6;
        double angle=0.0;
        if(shortaa<longaa) {
        	angle=longaa-shortaa;
        }else {
        	angle=shortaa-longaa;
        } 

  
        if(angle==360.0) {
        	angle=0.0;
        }
        else if(angle>180.0) {
        	angle=360.0-angle;
        }
     
        double cos = Math.cos(Math.toRadians(angle));
         ans= Math.sqrt( Math.pow(shortA, 2)+Math.pow(longB, 2)-2.0*shortA*longB*cos);

  
        System.out.println(ans);


    }
} public class Main {

    public static void main(String args[])  {
    	Scanner sc = new Scanner(System.in);
    	double shortA=sc.nextInt();
    	double longB =sc.nextInt();
    	double time=sc.nextInt();
    	double minute=sc.nextInt();
    	double all=360;
    	double ans=0.0;
        double timeMinute=60.0*time+minute;
        double shortaa=(timeMinute/720.0)*360;
        double longaa =minute*6;
        double angle=0.0;
        if(shortaa<longaa) {
        	angle=longaa-shortaa;
        }else {
        	angle=shortaa-longaa;
        } 

  
        if(angle==360.0) {
        	angle=0.0;
        }
        else if(angle>180.0) {
        	angle=360.0-angle;
        }
     
        double cos = Math.cos(Math.toRadians(angle));
         ans= Math.sqrt( Math.pow(shortA, 2)+Math.pow(longB, 2)-2.0*shortA*longB*cos);

  
        System.out.println(ans);


    }
} Main

import java.util.*;


 
public class Main {

    public static void main(String args[])  {
    	Scanner sc = new Scanner(System.in);
    	double shortA=sc.nextInt();
    	double longB =sc.nextInt();
    	double time=sc.nextInt();
    	double minute=sc.nextInt();
    	double all=360;
    	double ans=0.0;
        double timeMinute=60.0*time+minute;
        double shortaa=(timeMinute/720.0)*360;
        double longaa =minute*6;
        double angle=0.0;
        if(shortaa<longaa) {
        	angle=longaa-shortaa;
        }else {
        	angle=shortaa-longaa;
        } 

  
        if(angle==360.0) {
        	angle=0.0;
        }
        else if(angle>180.0) {
        	angle=360.0-angle;
        }
     
        double cos = Math.cos(Math.toRadians(angle));
         ans= Math.sqrt( Math.pow(shortA, 2)+Math.pow(longB, 2)-2.0*shortA*longB*cos);

  
        System.out.println(ans);


    }
}