import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
      	int a  = sc.nextInt();
      	int b  = sc.nextInt();
      	double h  = sc.nextDouble();
      	double m  = sc.nextDouble();
      	double hk = ((h / 12) * 360) + ((m / 60) * 30);
      	//System.out.println(hk);
      	double mk = 360 * (m / 60);
      	//System.out.println(mk);
      	double k = 0;
      	if(mk >= hk){
          k = mk -hk;
        }else{
          k = hk - mk; 
        }
      	if (k>=180){
          k = 360 - k;
        }
      	//System.out.println(k);      
      	double cosk = Math.cos(Math.toRadians(k));
      	//System.out.println(cosk);      
       	double c = (a*a) + (b*b) - (2*a*b*cosk);
        System.out.println(Math.sqrt(c));
    }
} import java.util.*; util.* java class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
      	int a  = sc.nextInt();
      	int b  = sc.nextInt();
      	double h  = sc.nextDouble();
      	double m  = sc.nextDouble();
      	double hk = ((h / 12) * 360) + ((m / 60) * 30);
      	//System.out.println(hk);
      	double mk = 360 * (m / 60);
      	//System.out.println(mk);
      	double k = 0;
      	if(mk >= hk){
          k = mk -hk;
        }else{
          k = hk - mk; 
        }
      	if (k>=180){
          k = 360 - k;
        }
      	//System.out.println(k);      
      	double cosk = Math.cos(Math.toRadians(k));
      	//System.out.println(cosk);      
       	double c = (a*a) + (b*b) - (2*a*b*cosk);
        System.out.println(Math.sqrt(c));
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
      	int a  = sc.nextInt();
      	int b  = sc.nextInt();
      	double h  = sc.nextDouble();
      	double m  = sc.nextDouble();
      	double hk = ((h / 12) * 360) + ((m / 60) * 30);
      	//System.out.println(hk);
      	double mk = 360 * (m / 60);
      	//System.out.println(mk);
      	double k = 0;
      	if(mk >= hk){
          k = mk -hk;
        }else{
          k = hk - mk; 
        }
      	if (k>=180){
          k = 360 - k;
        }
      	//System.out.println(k);      
      	double cosk = Math.cos(Math.toRadians(k));
      	//System.out.println(cosk);      
       	double c = (a*a) + (b*b) - (2*a*b*cosk);
        System.out.println(Math.sqrt(c));
    } main {
        Scanner sc = new Scanner(System.in);
      	int a  = sc.nextInt();
      	int b  = sc.nextInt();
      	double h  = sc.nextDouble();
      	double m  = sc.nextDouble();
      	double hk = ((h / 12) * 360) + ((m / 60) * 30);
      	//System.out.println(hk);
      	double mk = 360 * (m / 60);
      	//System.out.println(mk);
      	double k = 0;
      	if(mk >= hk){
          k = mk -hk;
        }else{
          k = hk - mk; 
        }
      	if (k>=180){
          k = 360 - k;
        }
      	//System.out.println(k);      
      	double cosk = Math.cos(Math.toRadians(k));
      	//System.out.println(cosk);      
       	double c = (a*a) + (b*b) - (2*a*b*cosk);
        System.out.println(Math.sqrt(c));
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int a  = sc.nextInt(); a sc.nextInt() sc.nextInt sc int b  = sc.nextInt(); b sc.nextInt() sc.nextInt sc double h  = sc.nextDouble(); h sc.nextDouble() sc.nextDouble sc double m  = sc.nextDouble(); m sc.nextDouble() sc.nextDouble sc double hk = ((h / 12) * 360) + ((m / 60) * 30); hk ((h / 12) * 360) + ((m / 60) * 30) ((h / 12) * 360) (h / 12) h 12 360 ((m / 60) * 30) (m / 60) m 60 30 double mk = 360 * (m / 60); mk 360 * (m / 60) 360 (m / 60) m 60 double k = 0; k 0 if(mk >= hk){
          k = mk -hk;
        }else{
          k = hk - mk; 
        } mk >= hk mk hk {
          k = mk -hk;
        } k = mk -hk k mk -hk mk hk {
          k = hk - mk; 
        } k = hk - mk k hk - mk hk mk if (k>=180){
          k = 360 - k;
        } k>=180 k 180 {
          k = 360 - k;
        } k = 360 - k k 360 - k 360 k double cosk = Math.cos(Math.toRadians(k)); cosk Math.cos(Math.toRadians(k)) Math.cos Math Math.toRadians(k) Math.toRadians Math k double c = (a*a) + (b*b) - (2*a*b*cosk); c (a*a) + (b*b) - (2*a*b*cosk) (a*a) + (b*b) (a*a) a a (b*b) b b (2*a*b*cosk) b 2*a*b*cosk 2 a b cosk System.out.println(Math.sqrt(c)) System.out.println System.out System System.out Math.sqrt(c) Math.sqrt Math c String[] args args
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
      	int a  = sc.nextInt();
      	int b  = sc.nextInt();
      	double h  = sc.nextDouble();
      	double m  = sc.nextDouble();
      	double hk = ((h / 12) * 360) + ((m / 60) * 30);
      	//System.out.println(hk);
      	double mk = 360 * (m / 60);
      	//System.out.println(mk);
      	double k = 0;
      	if(mk >= hk){
          k = mk -hk;
        }else{
          k = hk - mk; 
        }
      	if (k>=180){
          k = 360 - k;
        }
      	//System.out.println(k);      
      	double cosk = Math.cos(Math.toRadians(k));
      	//System.out.println(cosk);      
       	double c = (a*a) + (b*b) - (2*a*b*cosk);
        System.out.println(Math.sqrt(c));
    }
}