import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void fun(int a, int b, int h, int m) {

        double oneH = 2 * Math.PI / 12.0;
        double angleH = oneH * (h + m / 60.0);
        double oneM = 2 * Math.PI / 60.0;
        double angleM = oneM * m;

//        double angle = angleH - angleM;
        double angle = angleM - angleH;


        double ans = a * a + b * b - 2 * a * b * Math.cos(angle);
        System.out.println(Math.sqrt(ans));
    }



    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String line = in.readLine();
        String[] ss=line.split(" ");
        int a = Integer.valueOf(ss[0]);
        int b = Integer.valueOf(ss[1]);
        int h = Integer.valueOf(ss[2]);
        int m = Integer.valueOf(ss[3]);
        fun(a, b, h, m);
    }



} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

    public static void fun(int a, int b, int h, int m) {

        double oneH = 2 * Math.PI / 12.0;
        double angleH = oneH * (h + m / 60.0);
        double oneM = 2 * Math.PI / 60.0;
        double angleM = oneM * m;

//        double angle = angleH - angleM;
        double angle = angleM - angleH;


        double ans = a * a + b * b - 2 * a * b * Math.cos(angle);
        System.out.println(Math.sqrt(ans));
    }



    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String line = in.readLine();
        String[] ss=line.split(" ");
        int a = Integer.valueOf(ss[0]);
        int b = Integer.valueOf(ss[1]);
        int h = Integer.valueOf(ss[2]);
        int m = Integer.valueOf(ss[3]);
        fun(a, b, h, m);
    }



} Main public static void fun(int a, int b, int h, int m) {

        double oneH = 2 * Math.PI / 12.0;
        double angleH = oneH * (h + m / 60.0);
        double oneM = 2 * Math.PI / 60.0;
        double angleM = oneM * m;

//        double angle = angleH - angleM;
        double angle = angleM - angleH;


        double ans = a * a + b * b - 2 * a * b * Math.cos(angle);
        System.out.println(Math.sqrt(ans));
    } fun {

        double oneH = 2 * Math.PI / 12.0;
        double angleH = oneH * (h + m / 60.0);
        double oneM = 2 * Math.PI / 60.0;
        double angleM = oneM * m;

//        double angle = angleH - angleM;
        double angle = angleM - angleH;


        double ans = a * a + b * b - 2 * a * b * Math.cos(angle);
        System.out.println(Math.sqrt(ans));
    } double oneH = 2 * Math.PI / 12.0; oneH 2 * Math.PI / 12.0 2 * Math.PI 2 Math.PI Math Math.PI 12.0 double angleH = oneH * (h + m / 60.0); angleH oneH * (h + m / 60.0) oneH (h + m / 60.0) h m / 60.0 m 60.0 double oneM = 2 * Math.PI / 60.0; oneM 2 * Math.PI / 60.0 2 * Math.PI 2 Math.PI Math Math.PI 60.0 double angleM = oneM * m; angleM oneM * m oneM m double angle = angleM - angleH; angle angleM - angleH angleM angleH double ans = a * a + b * b - 2 * a * b * Math.cos(angle); ans a * a + b * b - 2 * a * b * Math.cos(angle) a * a + b * b a * a a a b * b b b 2 * a * b * Math.cos(angle) b 2 * a * b * Math.cos(angle) 2 a b Math.cos(angle) Math.cos Math angle System.out.println(Math.sqrt(ans)) System.out.println System.out System System.out Math.sqrt(ans) Math.sqrt Math ans int a a int b b int h h int m m public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String line = in.readLine();
        String[] ss=line.split(" ");
        int a = Integer.valueOf(ss[0]);
        int b = Integer.valueOf(ss[1]);
        int h = Integer.valueOf(ss[2]);
        int m = Integer.valueOf(ss[3]);
        fun(a, b, h, m);
    } main {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String line = in.readLine();
        String[] ss=line.split(" ");
        int a = Integer.valueOf(ss[0]);
        int b = Integer.valueOf(ss[1]);
        int h = Integer.valueOf(ss[2]);
        int m = Integer.valueOf(ss[3]);
        fun(a, b, h, m);
    } BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); in new BufferedReader(new InputStreamReader(System.in)) String line = in.readLine(); line in.readLine() in.readLine in String[] ss=line.split(" "); ss line.split(" ") line.split line " " int a = Integer.valueOf(ss[0]); a Integer.valueOf(ss[0]) Integer.valueOf Integer ss[0] ss 0 int b = Integer.valueOf(ss[1]); b Integer.valueOf(ss[1]) Integer.valueOf Integer ss[1] ss 1 int h = Integer.valueOf(ss[2]); h Integer.valueOf(ss[2]) Integer.valueOf Integer ss[2] ss 2 int m = Integer.valueOf(ss[3]); m Integer.valueOf(ss[3]) Integer.valueOf Integer ss[3] ss 3 fun(a, b, h, m) fun a b h m String[] args args public class Main {

    public static void fun(int a, int b, int h, int m) {

        double oneH = 2 * Math.PI / 12.0;
        double angleH = oneH * (h + m / 60.0);
        double oneM = 2 * Math.PI / 60.0;
        double angleM = oneM * m;

//        double angle = angleH - angleM;
        double angle = angleM - angleH;


        double ans = a * a + b * b - 2 * a * b * Math.cos(angle);
        System.out.println(Math.sqrt(ans));
    }



    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String line = in.readLine();
        String[] ss=line.split(" ");
        int a = Integer.valueOf(ss[0]);
        int b = Integer.valueOf(ss[1]);
        int h = Integer.valueOf(ss[2]);
        int m = Integer.valueOf(ss[3]);
        fun(a, b, h, m);
    }



} public class Main {

    public static void fun(int a, int b, int h, int m) {

        double oneH = 2 * Math.PI / 12.0;
        double angleH = oneH * (h + m / 60.0);
        double oneM = 2 * Math.PI / 60.0;
        double angleM = oneM * m;

//        double angle = angleH - angleM;
        double angle = angleM - angleH;


        double ans = a * a + b * b - 2 * a * b * Math.cos(angle);
        System.out.println(Math.sqrt(ans));
    }



    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String line = in.readLine();
        String[] ss=line.split(" ");
        int a = Integer.valueOf(ss[0]);
        int b = Integer.valueOf(ss[1]);
        int h = Integer.valueOf(ss[2]);
        int m = Integer.valueOf(ss[3]);
        fun(a, b, h, m);
    }



} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void fun(int a, int b, int h, int m) {

        double oneH = 2 * Math.PI / 12.0;
        double angleH = oneH * (h + m / 60.0);
        double oneM = 2 * Math.PI / 60.0;
        double angleM = oneM * m;

//        double angle = angleH - angleM;
        double angle = angleM - angleH;


        double ans = a * a + b * b - 2 * a * b * Math.cos(angle);
        System.out.println(Math.sqrt(ans));
    }



    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String line = in.readLine();
        String[] ss=line.split(" ");
        int a = Integer.valueOf(ss[0]);
        int b = Integer.valueOf(ss[1]);
        int h = Integer.valueOf(ss[2]);
        int m = Integer.valueOf(ss[3]);
        fun(a, b, h, m);
    }



}
