import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;
public class Main
{
	
	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
	    int A=scan.nextInt();
	    int B=scan.nextInt();
	    int H=scan.nextInt();
	    int M=scan.nextInt();
	    double mangle = (360.0/60.0)*M;
	    double hangle = (30.0*H)+(30.0/360.0)*mangle;
	    double angle = Math.abs(mangle-hangle);
	    if(angle>180) angle= 360-angle;
	    double ans = A*A+B*B-2*A*B*Math.cos(angle*(Math.PI/180));
	    ans = Math.sqrt(ans);
	    System.out.println(ans);
	}
} import java.util.*; util.* java import java.lang.*; lang.* java import java.io.*; io.* java import java.math.*; math.* java public class Main
{
	
	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
	    int A=scan.nextInt();
	    int B=scan.nextInt();
	    int H=scan.nextInt();
	    int M=scan.nextInt();
	    double mangle = (360.0/60.0)*M;
	    double hangle = (30.0*H)+(30.0/360.0)*mangle;
	    double angle = Math.abs(mangle-hangle);
	    if(angle>180) angle= 360-angle;
	    double ans = A*A+B*B-2*A*B*Math.cos(angle*(Math.PI/180));
	    ans = Math.sqrt(ans);
	    System.out.println(ans);
	}
} Main public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
	    int A=scan.nextInt();
	    int B=scan.nextInt();
	    int H=scan.nextInt();
	    int M=scan.nextInt();
	    double mangle = (360.0/60.0)*M;
	    double hangle = (30.0*H)+(30.0/360.0)*mangle;
	    double angle = Math.abs(mangle-hangle);
	    if(angle>180) angle= 360-angle;
	    double ans = A*A+B*B-2*A*B*Math.cos(angle*(Math.PI/180));
	    ans = Math.sqrt(ans);
	    System.out.println(ans);
	} main {
		Scanner scan = new Scanner(System.in);
	    int A=scan.nextInt();
	    int B=scan.nextInt();
	    int H=scan.nextInt();
	    int M=scan.nextInt();
	    double mangle = (360.0/60.0)*M;
	    double hangle = (30.0*H)+(30.0/360.0)*mangle;
	    double angle = Math.abs(mangle-hangle);
	    if(angle>180) angle= 360-angle;
	    double ans = A*A+B*B-2*A*B*Math.cos(angle*(Math.PI/180));
	    ans = Math.sqrt(ans);
	    System.out.println(ans);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int A=scan.nextInt(); A scan.nextInt() scan.nextInt scan int B=scan.nextInt(); B scan.nextInt() scan.nextInt scan int H=scan.nextInt(); H scan.nextInt() scan.nextInt scan int M=scan.nextInt(); M scan.nextInt() scan.nextInt scan double mangle = (360.0/60.0)*M; mangle (360.0/60.0)*M (360.0/60.0) 360.0 60.0 M double hangle = (30.0*H)+(30.0/360.0)*mangle; hangle (30.0*H)+(30.0/360.0)*mangle (30.0*H) 30.0 H (30.0/360.0)*mangle (30.0/360.0) 30.0 360.0 mangle double angle = Math.abs(mangle-hangle); angle Math.abs(mangle-hangle) Math.abs Math mangle-hangle mangle hangle if(angle>180) angle= 360-angle; angle>180 angle 180 angle= 360-angle angle 360-angle 360 angle double ans = A*A+B*B-2*A*B*Math.cos(angle*(Math.PI/180)); ans A*A+B*B-2*A*B*Math.cos(angle*(Math.PI/180)) A*A+B*B A*A A A B*B B B 2*A*B*Math.cos(angle*(Math.PI/180)) B 2*A*B*Math.cos(angle*(Math.PI/180)) 2 A B Math.cos(angle*(Math.PI/180)) Math.cos Math angle*(Math.PI/180) angle (Math.PI/180) Math.PI Math Math.PI 180 ans = Math.sqrt(ans) ans Math.sqrt(ans) Math.sqrt Math ans 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 scan = new Scanner(System.in);
	    int A=scan.nextInt();
	    int B=scan.nextInt();
	    int H=scan.nextInt();
	    int M=scan.nextInt();
	    double mangle = (360.0/60.0)*M;
	    double hangle = (30.0*H)+(30.0/360.0)*mangle;
	    double angle = Math.abs(mangle-hangle);
	    if(angle>180) angle= 360-angle;
	    double ans = A*A+B*B-2*A*B*Math.cos(angle*(Math.PI/180));
	    ans = Math.sqrt(ans);
	    System.out.println(ans);
	}
} public class Main
{
	
	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
	    int A=scan.nextInt();
	    int B=scan.nextInt();
	    int H=scan.nextInt();
	    int M=scan.nextInt();
	    double mangle = (360.0/60.0)*M;
	    double hangle = (30.0*H)+(30.0/360.0)*mangle;
	    double angle = Math.abs(mangle-hangle);
	    if(angle>180) angle= 360-angle;
	    double ans = A*A+B*B-2*A*B*Math.cos(angle*(Math.PI/180));
	    ans = Math.sqrt(ans);
	    System.out.println(ans);
	}
} Main
import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;
public class Main
{
	
	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
	    int A=scan.nextInt();
	    int B=scan.nextInt();
	    int H=scan.nextInt();
	    int M=scan.nextInt();
	    double mangle = (360.0/60.0)*M;
	    double hangle = (30.0*H)+(30.0/360.0)*mangle;
	    double angle = Math.abs(mangle-hangle);
	    if(angle>180) angle= 360-angle;
	    double ans = A*A+B*B-2*A*B*Math.cos(angle*(Math.PI/180));
	    ans = Math.sqrt(ans);
	    System.out.println(ans);
	}
}