import java.util.Scanner;
import java.math.*;
 
class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
 
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();
        sc.close();
 
        //短針と長針のなす角（度数）
        double degree = (30*h + 0.5*m) - 6*m;
 
        double distance = Math.sqrt(a*a + b*b -2*a*b*Math.cos(Math.toRadians(degree)));
 
        System.out.println(distance);
    }    
} import java.util.Scanner; Scanner java.util import java.math.*; math.* java class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
 
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();
        sc.close();
 
        //短針と長針のなす角（度数）
        double degree = (30*h + 0.5*m) - 6*m;
 
        double distance = Math.sqrt(a*a + b*b -2*a*b*Math.cos(Math.toRadians(degree)));
 
        System.out.println(distance);
    }    
} Main public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
 
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();
        sc.close();
 
        //短針と長針のなす角（度数）
        double degree = (30*h + 0.5*m) - 6*m;
 
        double distance = Math.sqrt(a*a + b*b -2*a*b*Math.cos(Math.toRadians(degree)));
 
        System.out.println(distance);
    } main {
        Scanner sc = new Scanner(System.in);
 
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();
        sc.close();
 
        //短針と長針のなす角（度数）
        double degree = (30*h + 0.5*m) - 6*m;
 
        double distance = Math.sqrt(a*a + b*b -2*a*b*Math.cos(Math.toRadians(degree)));
 
        System.out.println(distance);
    } 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 int h = sc.nextInt(); h sc.nextInt() sc.nextInt sc int m = sc.nextInt(); m sc.nextInt() sc.nextInt sc sc.close() sc.close sc double degree = (30*h + 0.5*m) - 6*m; degree (30*h + 0.5*m) - 6*m (30*h + 0.5*m) 30*h 30 h 0.5*m 0.5 m 6*m 6 m double distance = Math.sqrt(a*a + b*b -2*a*b*Math.cos(Math.toRadians(degree))); distance Math.sqrt(a*a + b*b -2*a*b*Math.cos(Math.toRadians(degree))) Math.sqrt Math a*a + b*b -2*a*b*Math.cos(Math.toRadians(degree)) a*a + b*b a*a a a b*b b b 2*a*b*Math.cos(Math.toRadians(degree)) b 2*a*b*Math.cos(Math.toRadians(degree)) 2 a b Math.cos(Math.toRadians(degree)) Math.cos Math Math.toRadians(degree) Math.toRadians Math degree System.out.println(distance) System.out.println System.out System System.out distance String args[] args
import java.util.Scanner;
import java.math.*;
 
class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
 
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();
        sc.close();
 
        //短針と長針のなす角（度数）
        double degree = (30*h + 0.5*m) - 6*m;
 
        double distance = Math.sqrt(a*a + b*b -2*a*b*Math.cos(Math.toRadians(degree)));
 
        System.out.println(distance);
    }    
}