import java.util.*;
import java.io.*;
 
public class Main {
    public static void main (final String[] args) {
        final Scanner sc = new Scanner(System.in);
      	double a = Double.parseDouble(sc.next());
        double b = Double.parseDouble(sc.next());
      	double h = Double.parseDouble(sc.next());
      	double m = Double.parseDouble(sc.next());
        
      	h = 2*Math.PI*h/12 + 2*Math.PI*m/720;
      	m = 2*Math.PI*m/60;
      
      	if (Math.abs(h - m) > Math.PI) h = 2*Math.PI - Math.abs(h - m);
      	else h = Math.abs(h - m);
      	
      	double result = Math.sqrt(a*a + b*b - 2*a*b*Math.cos(h));
      	System.out.println(result);
    }
} import java.util.*; util.* java import java.io.*; io.* java public class Main {
    public static void main (final String[] args) {
        final Scanner sc = new Scanner(System.in);
      	double a = Double.parseDouble(sc.next());
        double b = Double.parseDouble(sc.next());
      	double h = Double.parseDouble(sc.next());
      	double m = Double.parseDouble(sc.next());
        
      	h = 2*Math.PI*h/12 + 2*Math.PI*m/720;
      	m = 2*Math.PI*m/60;
      
      	if (Math.abs(h - m) > Math.PI) h = 2*Math.PI - Math.abs(h - m);
      	else h = Math.abs(h - m);
      	
      	double result = Math.sqrt(a*a + b*b - 2*a*b*Math.cos(h));
      	System.out.println(result);
    }
} Main public static void main (final String[] args) {
        final Scanner sc = new Scanner(System.in);
      	double a = Double.parseDouble(sc.next());
        double b = Double.parseDouble(sc.next());
      	double h = Double.parseDouble(sc.next());
      	double m = Double.parseDouble(sc.next());
        
      	h = 2*Math.PI*h/12 + 2*Math.PI*m/720;
      	m = 2*Math.PI*m/60;
      
      	if (Math.abs(h - m) > Math.PI) h = 2*Math.PI - Math.abs(h - m);
      	else h = Math.abs(h - m);
      	
      	double result = Math.sqrt(a*a + b*b - 2*a*b*Math.cos(h));
      	System.out.println(result);
    } main {
        final Scanner sc = new Scanner(System.in);
      	double a = Double.parseDouble(sc.next());
        double b = Double.parseDouble(sc.next());
      	double h = Double.parseDouble(sc.next());
      	double m = Double.parseDouble(sc.next());
        
      	h = 2*Math.PI*h/12 + 2*Math.PI*m/720;
      	m = 2*Math.PI*m/60;
      
      	if (Math.abs(h - m) > Math.PI) h = 2*Math.PI - Math.abs(h - m);
      	else h = Math.abs(h - m);
      	
      	double result = Math.sqrt(a*a + b*b - 2*a*b*Math.cos(h));
      	System.out.println(result);
    } final Scanner sc = new Scanner(System.in); sc new Scanner(System.in) double a = Double.parseDouble(sc.next()); a Double.parseDouble(sc.next()) Double.parseDouble Double sc.next() sc.next sc double b = Double.parseDouble(sc.next()); b Double.parseDouble(sc.next()) Double.parseDouble Double sc.next() sc.next sc double h = Double.parseDouble(sc.next()); h Double.parseDouble(sc.next()) Double.parseDouble Double sc.next() sc.next sc double m = Double.parseDouble(sc.next()); m Double.parseDouble(sc.next()) Double.parseDouble Double sc.next() sc.next sc h = 2*Math.PI*h/12 + 2*Math.PI*m/720 h 2*Math.PI*h/12 + 2*Math.PI*m/720 2*Math.PI*h/12 2*Math.PI*h 2*Math.PI*h 2 Math.PI Math Math.PI h 12 2*Math.PI*m/720 2*Math.PI*m 2*Math.PI*m 2 Math.PI Math Math.PI m 720 m = 2*Math.PI*m/60 m 2*Math.PI*m/60 2*Math.PI*m 2*Math.PI*m 2 Math.PI Math Math.PI m 60 if (Math.abs(h - m) > Math.PI) h = 2*Math.PI - Math.abs(h - m);
      	else h = Math.abs(h - m); Math.abs(h - m) > Math.PI Math.abs(h - m) Math.abs Math h - m h m Math.PI Math Math.PI h = 2*Math.PI - Math.abs(h - m) h 2*Math.PI - Math.abs(h - m) 2*Math.PI 2 Math.PI Math Math.PI Math.abs(h - m) Math.abs Math h - m h m h = Math.abs(h - m) h Math.abs(h - m) Math.abs Math h - m h m double result = Math.sqrt(a*a + b*b - 2*a*b*Math.cos(h)); result Math.sqrt(a*a + b*b - 2*a*b*Math.cos(h)) Math.sqrt Math a*a + b*b - 2*a*b*Math.cos(h) a*a + b*b a*a a a b*b b b 2*a*b*Math.cos(h) b 2*a*b*Math.cos(h) 2 a b Math.cos(h) Math.cos Math h System.out.println(result) System.out.println System.out System System.out result final String[] args args public class Main {
    public static void main (final String[] args) {
        final Scanner sc = new Scanner(System.in);
      	double a = Double.parseDouble(sc.next());
        double b = Double.parseDouble(sc.next());
      	double h = Double.parseDouble(sc.next());
      	double m = Double.parseDouble(sc.next());
        
      	h = 2*Math.PI*h/12 + 2*Math.PI*m/720;
      	m = 2*Math.PI*m/60;
      
      	if (Math.abs(h - m) > Math.PI) h = 2*Math.PI - Math.abs(h - m);
      	else h = Math.abs(h - m);
      	
      	double result = Math.sqrt(a*a + b*b - 2*a*b*Math.cos(h));
      	System.out.println(result);
    }
} public class Main {
    public static void main (final String[] args) {
        final Scanner sc = new Scanner(System.in);
      	double a = Double.parseDouble(sc.next());
        double b = Double.parseDouble(sc.next());
      	double h = Double.parseDouble(sc.next());
      	double m = Double.parseDouble(sc.next());
        
      	h = 2*Math.PI*h/12 + 2*Math.PI*m/720;
      	m = 2*Math.PI*m/60;
      
      	if (Math.abs(h - m) > Math.PI) h = 2*Math.PI - Math.abs(h - m);
      	else h = Math.abs(h - m);
      	
      	double result = Math.sqrt(a*a + b*b - 2*a*b*Math.cos(h));
      	System.out.println(result);
    }
} Main
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main (final String[] args) {
        final Scanner sc = new Scanner(System.in);
      	double a = Double.parseDouble(sc.next());
        double b = Double.parseDouble(sc.next());
      	double h = Double.parseDouble(sc.next());
      	double m = Double.parseDouble(sc.next());
        
      	h = 2*Math.PI*h/12 + 2*Math.PI*m/720;
      	m = 2*Math.PI*m/60;
      
      	if (Math.abs(h - m) > Math.PI) h = 2*Math.PI - Math.abs(h - m);
      	else h = Math.abs(h - m);
      	
      	double result = Math.sqrt(a*a + b*b - 2*a*b*Math.cos(h));
      	System.out.println(result);
    }
}