import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();
        int min = h * 60 + m; //経過時間（min）
        double degLong = (min * 6) % 360;
        double degShort = (min * 0.5) % 360;
        double deg = Math.abs(degLong - degShort);
        double rad = Math.toRadians(deg);
        double cos = Math.cos(rad);
        double ans = Math.sqrt(a*a + b*b - 2*a*b*cos);
        System.out.println(ans);
    }
} import java.util.*; util.* java import java.lang.*; lang.* java import java.io.*; io.* java public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();
        int min = h * 60 + m; //経過時間（min）
        double degLong = (min * 6) % 360;
        double degShort = (min * 0.5) % 360;
        double deg = Math.abs(degLong - degShort);
        double rad = Math.toRadians(deg);
        double cos = Math.cos(rad);
        double ans = Math.sqrt(a*a + b*b - 2*a*b*cos);
        System.out.println(ans);
    }
} Main public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();
        int min = h * 60 + m; //経過時間（min）
        double degLong = (min * 6) % 360;
        double degShort = (min * 0.5) % 360;
        double deg = Math.abs(degLong - degShort);
        double rad = Math.toRadians(deg);
        double cos = Math.cos(rad);
        double ans = Math.sqrt(a*a + b*b - 2*a*b*cos);
        System.out.println(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 min = h * 60 + m; //経過時間（min）
        double degLong = (min * 6) % 360;
        double degShort = (min * 0.5) % 360;
        double deg = Math.abs(degLong - degShort);
        double rad = Math.toRadians(deg);
        double cos = Math.cos(rad);
        double ans = Math.sqrt(a*a + b*b - 2*a*b*cos);
        System.out.println(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 min = h * 60 + m; min h * 60 + m h * 60 h 60 m double degLong = (min * 6) % 360; degLong (min * 6) % 360 (min * 6) min 6 360 double degShort = (min * 0.5) % 360; degShort (min * 0.5) % 360 (min * 0.5) min 0.5 360 double deg = Math.abs(degLong - degShort); deg Math.abs(degLong - degShort) Math.abs Math degLong - degShort degLong degShort double rad = Math.toRadians(deg); rad Math.toRadians(deg) Math.toRadians Math deg double cos = Math.cos(rad); cos Math.cos(rad) Math.cos Math rad double ans = Math.sqrt(a*a + b*b - 2*a*b*cos); ans Math.sqrt(a*a + b*b - 2*a*b*cos) Math.sqrt Math a*a + b*b - 2*a*b*cos a*a + b*b a*a a a b*b b b 2*a*b*cos b 2*a*b*cos 2 a b cos System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();
        int min = h * 60 + m; //経過時間（min）
        double degLong = (min * 6) % 360;
        double degShort = (min * 0.5) % 360;
        double deg = Math.abs(degLong - degShort);
        double rad = Math.toRadians(deg);
        double cos = Math.cos(rad);
        double ans = Math.sqrt(a*a + b*b - 2*a*b*cos);
        System.out.println(ans);
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();
        int min = h * 60 + m; //経過時間（min）
        double degLong = (min * 6) % 360;
        double degShort = (min * 0.5) % 360;
        double deg = Math.abs(degLong - degShort);
        double rad = Math.toRadians(deg);
        double cos = Math.cos(rad);
        double ans = Math.sqrt(a*a + b*b - 2*a*b*cos);
        System.out.println(ans);
    }
} Main
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();
        int min = h * 60 + m; //経過時間（min）
        double degLong = (min * 6) % 360;
        double degShort = (min * 0.5) % 360;
        double deg = Math.abs(degLong - degShort);
        double rad = Math.toRadians(deg);
        double cos = Math.cos(rad);
        double ans = Math.sqrt(a*a + b*b - 2*a*b*cos);
        System.out.println(ans);
    }
}
