import java.util.Scanner;

public 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();
        int time = h*60+m;
        double hd = 0.5*time;
        double md = 6.0*m;

        double hx = Math.sin(Math.toRadians(hd)) * a;
        double hy = Math.cos(Math.toRadians(hd)) * a;
        double mx = Math.sin(Math.toRadians(md)) * b;
        double my = Math.cos(Math.toRadians(md)) * b;

        double x = (hx - mx);
        if (x<0) {
            x *= -1;
        }
        double y = (hy - my);
        if (y<0) {
            y *= -1;
        }
        double ans = x*x + y*y;
        System.out.println(Math.sqrt(ans));
    }
} import java.util.Scanner; Scanner java.util public 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();
        int time = h*60+m;
        double hd = 0.5*time;
        double md = 6.0*m;

        double hx = Math.sin(Math.toRadians(hd)) * a;
        double hy = Math.cos(Math.toRadians(hd)) * a;
        double mx = Math.sin(Math.toRadians(md)) * b;
        double my = Math.cos(Math.toRadians(md)) * b;

        double x = (hx - mx);
        if (x<0) {
            x *= -1;
        }
        double y = (hy - my);
        if (y<0) {
            y *= -1;
        }
        double ans = x*x + y*y;
        System.out.println(Math.sqrt(ans));
    }
} 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();
        int time = h*60+m;
        double hd = 0.5*time;
        double md = 6.0*m;

        double hx = Math.sin(Math.toRadians(hd)) * a;
        double hy = Math.cos(Math.toRadians(hd)) * a;
        double mx = Math.sin(Math.toRadians(md)) * b;
        double my = Math.cos(Math.toRadians(md)) * b;

        double x = (hx - mx);
        if (x<0) {
            x *= -1;
        }
        double y = (hy - my);
        if (y<0) {
            y *= -1;
        }
        double ans = x*x + y*y;
        System.out.println(Math.sqrt(ans));
    } main {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();
        int time = h*60+m;
        double hd = 0.5*time;
        double md = 6.0*m;

        double hx = Math.sin(Math.toRadians(hd)) * a;
        double hy = Math.cos(Math.toRadians(hd)) * a;
        double mx = Math.sin(Math.toRadians(md)) * b;
        double my = Math.cos(Math.toRadians(md)) * b;

        double x = (hx - mx);
        if (x<0) {
            x *= -1;
        }
        double y = (hy - my);
        if (y<0) {
            y *= -1;
        }
        double ans = x*x + y*y;
        System.out.println(Math.sqrt(ans));
    } 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 int time = h*60+m; time h*60+m h*60 h 60 m double hd = 0.5*time; hd 0.5*time 0.5 time double md = 6.0*m; md 6.0*m 6.0 m double hx = Math.sin(Math.toRadians(hd)) * a; hx Math.sin(Math.toRadians(hd)) * a Math.sin(Math.toRadians(hd)) Math.sin Math Math.toRadians(hd) Math.toRadians Math hd a double hy = Math.cos(Math.toRadians(hd)) * a; hy Math.cos(Math.toRadians(hd)) * a Math.cos(Math.toRadians(hd)) Math.cos Math Math.toRadians(hd) Math.toRadians Math hd a double mx = Math.sin(Math.toRadians(md)) * b; mx Math.sin(Math.toRadians(md)) * b Math.sin(Math.toRadians(md)) Math.sin Math Math.toRadians(md) Math.toRadians Math md b double my = Math.cos(Math.toRadians(md)) * b; my Math.cos(Math.toRadians(md)) * b Math.cos(Math.toRadians(md)) Math.cos Math Math.toRadians(md) Math.toRadians Math md b double x = (hx - mx); x (hx - mx) hx mx if (x<0) {
            x *= -1;
        } x<0 x 0 {
            x *= -1;
        } x *= -1 x -1 1 double y = (hy - my); y (hy - my) hy my if (y<0) {
            y *= -1;
        } y<0 y 0 {
            y *= -1;
        } y *= -1 y -1 1 double ans = x*x + y*y; ans x*x + y*y x*x x x y*y y y System.out.println(Math.sqrt(ans)) System.out.println System.out System System.out Math.sqrt(ans) Math.sqrt Math ans String[] args args public 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();
        int time = h*60+m;
        double hd = 0.5*time;
        double md = 6.0*m;

        double hx = Math.sin(Math.toRadians(hd)) * a;
        double hy = Math.cos(Math.toRadians(hd)) * a;
        double mx = Math.sin(Math.toRadians(md)) * b;
        double my = Math.cos(Math.toRadians(md)) * b;

        double x = (hx - mx);
        if (x<0) {
            x *= -1;
        }
        double y = (hy - my);
        if (y<0) {
            y *= -1;
        }
        double ans = x*x + y*y;
        System.out.println(Math.sqrt(ans));
    }
} public 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();
        int time = h*60+m;
        double hd = 0.5*time;
        double md = 6.0*m;

        double hx = Math.sin(Math.toRadians(hd)) * a;
        double hy = Math.cos(Math.toRadians(hd)) * a;
        double mx = Math.sin(Math.toRadians(md)) * b;
        double my = Math.cos(Math.toRadians(md)) * b;

        double x = (hx - mx);
        if (x<0) {
            x *= -1;
        }
        double y = (hy - my);
        if (y<0) {
            y *= -1;
        }
        double ans = x*x + y*y;
        System.out.println(Math.sqrt(ans));
    }
} Main
import java.util.Scanner;

public 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();
        int time = h*60+m;
        double hd = 0.5*time;
        double md = 6.0*m;

        double hx = Math.sin(Math.toRadians(hd)) * a;
        double hy = Math.cos(Math.toRadians(hd)) * a;
        double mx = Math.sin(Math.toRadians(md)) * b;
        double my = Math.cos(Math.toRadians(md)) * b;

        double x = (hx - mx);
        if (x<0) {
            x *= -1;
        }
        double y = (hy - my);
        if (y<0) {
            y *= -1;
        }
        double ans = x*x + y*y;
        System.out.println(Math.sqrt(ans));
    }
}
