import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = Integer.parseInt(scan.next());
        int b = Integer.parseInt(scan.next());
        int h = Integer.parseInt(scan.next());
        int m = Integer.parseInt(scan.next());
        scan.close();

        double rad = Math.abs((double)(h * 60 + m) / 720 - (double)m / 60) * Math.PI * 2;

        double ans2 = a * a + b * b - 2 * a * b * Math.cos(rad);

            System.out.println(Math.sqrt(ans2));
       
    }

} import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = Integer.parseInt(scan.next());
        int b = Integer.parseInt(scan.next());
        int h = Integer.parseInt(scan.next());
        int m = Integer.parseInt(scan.next());
        scan.close();

        double rad = Math.abs((double)(h * 60 + m) / 720 - (double)m / 60) * Math.PI * 2;

        double ans2 = a * a + b * b - 2 * a * b * Math.cos(rad);

            System.out.println(Math.sqrt(ans2));
       
    }

} Main public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = Integer.parseInt(scan.next());
        int b = Integer.parseInt(scan.next());
        int h = Integer.parseInt(scan.next());
        int m = Integer.parseInt(scan.next());
        scan.close();

        double rad = Math.abs((double)(h * 60 + m) / 720 - (double)m / 60) * Math.PI * 2;

        double ans2 = a * a + b * b - 2 * a * b * Math.cos(rad);

            System.out.println(Math.sqrt(ans2));
       
    } main {
        Scanner scan = new Scanner(System.in);
        int a = Integer.parseInt(scan.next());
        int b = Integer.parseInt(scan.next());
        int h = Integer.parseInt(scan.next());
        int m = Integer.parseInt(scan.next());
        scan.close();

        double rad = Math.abs((double)(h * 60 + m) / 720 - (double)m / 60) * Math.PI * 2;

        double ans2 = a * a + b * b - 2 * a * b * Math.cos(rad);

            System.out.println(Math.sqrt(ans2));
       
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int a = Integer.parseInt(scan.next()); a Integer.parseInt(scan.next()) Integer.parseInt Integer scan.next() scan.next scan int b = Integer.parseInt(scan.next()); b Integer.parseInt(scan.next()) Integer.parseInt Integer scan.next() scan.next scan int h = Integer.parseInt(scan.next()); h Integer.parseInt(scan.next()) Integer.parseInt Integer scan.next() scan.next scan int m = Integer.parseInt(scan.next()); m Integer.parseInt(scan.next()) Integer.parseInt Integer scan.next() scan.next scan scan.close() scan.close scan double rad = Math.abs((double)(h * 60 + m) / 720 - (double)m / 60) * Math.PI * 2; rad Math.abs((double)(h * 60 + m) / 720 - (double)m / 60) * Math.PI * 2 Math.abs((double)(h * 60 + m) / 720 - (double)m / 60) * Math.PI * 2 Math.abs((double)(h * 60 + m) / 720 - (double)m / 60) Math.abs Math (double)(h * 60 + m) / 720 - (double)m / 60 (double)(h * 60 + m) / 720 (double)(h * 60 + m) h * 60 h 60 m 720 (double)m / 60 (double)m 60 Math.PI Math Math.PI 2 double ans2 = a * a + b * b - 2 * a * b * Math.cos(rad); ans2 a * a + b * b - 2 * a * b * Math.cos(rad) a * a + b * b a * a a a b * b b b 2 * a * b * Math.cos(rad) b 2 * a * b * Math.cos(rad) 2 a b Math.cos(rad) Math.cos Math rad System.out.println(Math.sqrt(ans2)) System.out.println System.out System System.out Math.sqrt(ans2) Math.sqrt Math ans2 String[] args args public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = Integer.parseInt(scan.next());
        int b = Integer.parseInt(scan.next());
        int h = Integer.parseInt(scan.next());
        int m = Integer.parseInt(scan.next());
        scan.close();

        double rad = Math.abs((double)(h * 60 + m) / 720 - (double)m / 60) * Math.PI * 2;

        double ans2 = a * a + b * b - 2 * a * b * Math.cos(rad);

            System.out.println(Math.sqrt(ans2));
       
    }

} public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = Integer.parseInt(scan.next());
        int b = Integer.parseInt(scan.next());
        int h = Integer.parseInt(scan.next());
        int m = Integer.parseInt(scan.next());
        scan.close();

        double rad = Math.abs((double)(h * 60 + m) / 720 - (double)m / 60) * Math.PI * 2;

        double ans2 = a * a + b * b - 2 * a * b * Math.cos(rad);

            System.out.println(Math.sqrt(ans2));
       
    }

} Main
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = Integer.parseInt(scan.next());
        int b = Integer.parseInt(scan.next());
        int h = Integer.parseInt(scan.next());
        int m = Integer.parseInt(scan.next());
        scan.close();

        double rad = Math.abs((double)(h * 60 + m) / 720 - (double)m / 60) * Math.PI * 2;

        double ans2 = a * a + b * b - 2 * a * b * Math.cos(rad);

            System.out.println(Math.sqrt(ans2));
       
    }

}