import java.util.Scanner;
class Main{
	public static void main(String[] args){
    	Scanner sr = new Scanner(System.in);
      	int A = sr.nextInt();
      	int B = sr.nextInt();
      	int H = sr.nextInt();
      	int M = sr.nextInt();
      	
      double angleA = (H*60+M)*Math.PI/360;    
      double angleB = (M*Math.PI)/30;
      double C = A*A+B*B-(2*A*B*Math.cos(Math.abs(angleA-angleB)));
      System.out.println(Math.sqrt(C));
    }
}  import java.util.Scanner; Scanner java.util class Main{
	public static void main(String[] args){
    	Scanner sr = new Scanner(System.in);
      	int A = sr.nextInt();
      	int B = sr.nextInt();
      	int H = sr.nextInt();
      	int M = sr.nextInt();
      	
      double angleA = (H*60+M)*Math.PI/360;    
      double angleB = (M*Math.PI)/30;
      double C = A*A+B*B-(2*A*B*Math.cos(Math.abs(angleA-angleB)));
      System.out.println(Math.sqrt(C));
    }
} Main public static void main(String[] args){
    	Scanner sr = new Scanner(System.in);
      	int A = sr.nextInt();
      	int B = sr.nextInt();
      	int H = sr.nextInt();
      	int M = sr.nextInt();
      	
      double angleA = (H*60+M)*Math.PI/360;    
      double angleB = (M*Math.PI)/30;
      double C = A*A+B*B-(2*A*B*Math.cos(Math.abs(angleA-angleB)));
      System.out.println(Math.sqrt(C));
    } main {
    	Scanner sr = new Scanner(System.in);
      	int A = sr.nextInt();
      	int B = sr.nextInt();
      	int H = sr.nextInt();
      	int M = sr.nextInt();
      	
      double angleA = (H*60+M)*Math.PI/360;    
      double angleB = (M*Math.PI)/30;
      double C = A*A+B*B-(2*A*B*Math.cos(Math.abs(angleA-angleB)));
      System.out.println(Math.sqrt(C));
    } Scanner sr = new Scanner(System.in); sr new Scanner(System.in) int A = sr.nextInt(); A sr.nextInt() sr.nextInt sr int B = sr.nextInt(); B sr.nextInt() sr.nextInt sr int H = sr.nextInt(); H sr.nextInt() sr.nextInt sr int M = sr.nextInt(); M sr.nextInt() sr.nextInt sr double angleA = (H*60+M)*Math.PI/360; angleA (H*60+M)*Math.PI/360 (H*60+M)*Math.PI (H*60+M) H*60 H 60 M Math.PI Math Math.PI 360 double angleB = (M*Math.PI)/30; angleB (M*Math.PI)/30 (M*Math.PI) M Math.PI Math Math.PI 30 double C = A*A+B*B-(2*A*B*Math.cos(Math.abs(angleA-angleB))); C A*A+B*B-(2*A*B*Math.cos(Math.abs(angleA-angleB))) A*A+B*B A*A A A B*B B B (2*A*B*Math.cos(Math.abs(angleA-angleB))) B 2*A*B*Math.cos(Math.abs(angleA-angleB)) 2 A B Math.cos(Math.abs(angleA-angleB)) Math.cos Math Math.abs(angleA-angleB) Math.abs Math angleA-angleB angleA angleB 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.Scanner;
class Main{
	public static void main(String[] args){
    	Scanner sr = new Scanner(System.in);
      	int A = sr.nextInt();
      	int B = sr.nextInt();
      	int H = sr.nextInt();
      	int M = sr.nextInt();
      	
      double angleA = (H*60+M)*Math.PI/360;    
      double angleB = (M*Math.PI)/30;
      double C = A*A+B*B-(2*A*B*Math.cos(Math.abs(angleA-angleB)));
      System.out.println(Math.sqrt(C));
    }
} 