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

class Main{
    public static void main(String args[])throws IOException{
        try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
            String[] input = br.readLine().split(" ");
            double A = Double.parseDouble(input[0]);
            double B = Double.parseDouble(input[1]);
            double H = Double.parseDouble(input[2]);
            double M = Double.parseDouble(input[3]);

            double h_r = 0;
            double m_r = 0;
            double r = 0;
            double result = 0;

            if(M == 0){
              m_r = 360;
              h_r = H * 30;
            }else{
              m_r = M * 6;
              h_r = H * 30 + M * 0.5;
            }

            //System.out.println(h_r);
            //System.out.println(m_r);

            if(H == 0 && M == 0){
              result = A - B;
            }else{
              r = Math.abs(h_r - m_r);
              if(r == 0){
                result = 0;
              }else{
                double cos = Math.cos(Math.toRadians(r));
                double a = Math.pow(A, 2);
                double b = Math.pow(B, 2);
                double tmp = a + b - (2 * A * B * cos);
                result = Math.sqrt(tmp);
              }
            }

            System.out.println(result);
        }

    }
} import java.util.*; util.* java import java.io.*; io.* java class Main{
    public static void main(String args[])throws IOException{
        try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
            String[] input = br.readLine().split(" ");
            double A = Double.parseDouble(input[0]);
            double B = Double.parseDouble(input[1]);
            double H = Double.parseDouble(input[2]);
            double M = Double.parseDouble(input[3]);

            double h_r = 0;
            double m_r = 0;
            double r = 0;
            double result = 0;

            if(M == 0){
              m_r = 360;
              h_r = H * 30;
            }else{
              m_r = M * 6;
              h_r = H * 30 + M * 0.5;
            }

            //System.out.println(h_r);
            //System.out.println(m_r);

            if(H == 0 && M == 0){
              result = A - B;
            }else{
              r = Math.abs(h_r - m_r);
              if(r == 0){
                result = 0;
              }else{
                double cos = Math.cos(Math.toRadians(r));
                double a = Math.pow(A, 2);
                double b = Math.pow(B, 2);
                double tmp = a + b - (2 * A * B * cos);
                result = Math.sqrt(tmp);
              }
            }

            System.out.println(result);
        }

    }
} Main public static void main(String args[])throws IOException{
        try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
            String[] input = br.readLine().split(" ");
            double A = Double.parseDouble(input[0]);
            double B = Double.parseDouble(input[1]);
            double H = Double.parseDouble(input[2]);
            double M = Double.parseDouble(input[3]);

            double h_r = 0;
            double m_r = 0;
            double r = 0;
            double result = 0;

            if(M == 0){
              m_r = 360;
              h_r = H * 30;
            }else{
              m_r = M * 6;
              h_r = H * 30 + M * 0.5;
            }

            //System.out.println(h_r);
            //System.out.println(m_r);

            if(H == 0 && M == 0){
              result = A - B;
            }else{
              r = Math.abs(h_r - m_r);
              if(r == 0){
                result = 0;
              }else{
                double cos = Math.cos(Math.toRadians(r));
                double a = Math.pow(A, 2);
                double b = Math.pow(B, 2);
                double tmp = a + b - (2 * A * B * cos);
                result = Math.sqrt(tmp);
              }
            }

            System.out.println(result);
        }

    } main {
        try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
            String[] input = br.readLine().split(" ");
            double A = Double.parseDouble(input[0]);
            double B = Double.parseDouble(input[1]);
            double H = Double.parseDouble(input[2]);
            double M = Double.parseDouble(input[3]);

            double h_r = 0;
            double m_r = 0;
            double r = 0;
            double result = 0;

            if(M == 0){
              m_r = 360;
              h_r = H * 30;
            }else{
              m_r = M * 6;
              h_r = H * 30 + M * 0.5;
            }

            //System.out.println(h_r);
            //System.out.println(m_r);

            if(H == 0 && M == 0){
              result = A - B;
            }else{
              r = Math.abs(h_r - m_r);
              if(r == 0){
                result = 0;
              }else{
                double cos = Math.cos(Math.toRadians(r));
                double a = Math.pow(A, 2);
                double b = Math.pow(B, 2);
                double tmp = a + b - (2 * A * B * cos);
                result = Math.sqrt(tmp);
              }
            }

            System.out.println(result);
        }

    } try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
            String[] input = br.readLine().split(" ");
            double A = Double.parseDouble(input[0]);
            double B = Double.parseDouble(input[1]);
            double H = Double.parseDouble(input[2]);
            double M = Double.parseDouble(input[3]);

            double h_r = 0;
            double m_r = 0;
            double r = 0;
            double result = 0;

            if(M == 0){
              m_r = 360;
              h_r = H * 30;
            }else{
              m_r = M * 6;
              h_r = H * 30 + M * 0.5;
            }

            //System.out.println(h_r);
            //System.out.println(m_r);

            if(H == 0 && M == 0){
              result = A - B;
            }else{
              r = Math.abs(h_r - m_r);
              if(r == 0){
                result = 0;
              }else{
                double cos = Math.cos(Math.toRadians(r));
                double a = Math.pow(A, 2);
                double b = Math.pow(B, 2);
                double tmp = a + b - (2 * A * B * cos);
                result = Math.sqrt(tmp);
              }
            }

            System.out.println(result);
        } {
            String[] input = br.readLine().split(" ");
            double A = Double.parseDouble(input[0]);
            double B = Double.parseDouble(input[1]);
            double H = Double.parseDouble(input[2]);
            double M = Double.parseDouble(input[3]);

            double h_r = 0;
            double m_r = 0;
            double r = 0;
            double result = 0;

            if(M == 0){
              m_r = 360;
              h_r = H * 30;
            }else{
              m_r = M * 6;
              h_r = H * 30 + M * 0.5;
            }

            //System.out.println(h_r);
            //System.out.println(m_r);

            if(H == 0 && M == 0){
              result = A - B;
            }else{
              r = Math.abs(h_r - m_r);
              if(r == 0){
                result = 0;
              }else{
                double cos = Math.cos(Math.toRadians(r));
                double a = Math.pow(A, 2);
                double b = Math.pow(B, 2);
                double tmp = a + b - (2 * A * B * cos);
                result = Math.sqrt(tmp);
              }
            }

            System.out.println(result);
        } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) new BufferedReader(new InputStreamReader(System.in)) String[] input = br.readLine().split(" "); input br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " double A = Double.parseDouble(input[0]); A Double.parseDouble(input[0]) Double.parseDouble Double input[0] input 0 double B = Double.parseDouble(input[1]); B Double.parseDouble(input[1]) Double.parseDouble Double input[1] input 1 double H = Double.parseDouble(input[2]); H Double.parseDouble(input[2]) Double.parseDouble Double input[2] input 2 double M = Double.parseDouble(input[3]); M Double.parseDouble(input[3]) Double.parseDouble Double input[3] input 3 double h_r = 0; h_r 0 double m_r = 0; m_r 0 double r = 0; r 0 double result = 0; result 0 if(M == 0){
              m_r = 360;
              h_r = H * 30;
            }else{
              m_r = M * 6;
              h_r = H * 30 + M * 0.5;
            } M == 0 M 0 {
              m_r = 360;
              h_r = H * 30;
            } m_r = 360 m_r 360 h_r = H * 30 h_r H * 30 H 30 {
              m_r = M * 6;
              h_r = H * 30 + M * 0.5;
            } m_r = M * 6 m_r M * 6 M 6 h_r = H * 30 + M * 0.5 h_r H * 30 + M * 0.5 H * 30 H 30 M * 0.5 M 0.5 if(H == 0 && M == 0){
              result = A - B;
            }else{
              r = Math.abs(h_r - m_r);
              if(r == 0){
                result = 0;
              }else{
                double cos = Math.cos(Math.toRadians(r));
                double a = Math.pow(A, 2);
                double b = Math.pow(B, 2);
                double tmp = a + b - (2 * A * B * cos);
                result = Math.sqrt(tmp);
              }
            } H == 0 && M == 0 H == 0 H 0 M == 0 M 0 {
              result = A - B;
            } result = A - B result A - B A B {
              r = Math.abs(h_r - m_r);
              if(r == 0){
                result = 0;
              }else{
                double cos = Math.cos(Math.toRadians(r));
                double a = Math.pow(A, 2);
                double b = Math.pow(B, 2);
                double tmp = a + b - (2 * A * B * cos);
                result = Math.sqrt(tmp);
              }
            } r = Math.abs(h_r - m_r) r Math.abs(h_r - m_r) Math.abs Math h_r - m_r h_r m_r if(r == 0){
                result = 0;
              }else{
                double cos = Math.cos(Math.toRadians(r));
                double a = Math.pow(A, 2);
                double b = Math.pow(B, 2);
                double tmp = a + b - (2 * A * B * cos);
                result = Math.sqrt(tmp);
              } r == 0 r 0 {
                result = 0;
              } result = 0 result 0 {
                double cos = Math.cos(Math.toRadians(r));
                double a = Math.pow(A, 2);
                double b = Math.pow(B, 2);
                double tmp = a + b - (2 * A * B * cos);
                result = Math.sqrt(tmp);
              } double cos = Math.cos(Math.toRadians(r)); cos Math.cos(Math.toRadians(r)) Math.cos Math Math.toRadians(r) Math.toRadians Math r double a = Math.pow(A, 2); a Math.pow(A, 2) Math.pow Math A 2 double b = Math.pow(B, 2); b Math.pow(B, 2) Math.pow Math B 2 double tmp = a + b - (2 * A * B * cos); tmp a + b - (2 * A * B * cos) a + b a b (2 * A * B * cos) B 2 * A * B * cos 2 A B cos result = Math.sqrt(tmp) result Math.sqrt(tmp) Math.sqrt Math tmp System.out.println(result) System.out.println System.out System System.out result String args[] args
import java.util.*;
import java.io.*;

class Main{
    public static void main(String args[])throws IOException{
        try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
            String[] input = br.readLine().split(" ");
            double A = Double.parseDouble(input[0]);
            double B = Double.parseDouble(input[1]);
            double H = Double.parseDouble(input[2]);
            double M = Double.parseDouble(input[3]);

            double h_r = 0;
            double m_r = 0;
            double r = 0;
            double result = 0;

            if(M == 0){
              m_r = 360;
              h_r = H * 30;
            }else{
              m_r = M * 6;
              h_r = H * 30 + M * 0.5;
            }

            //System.out.println(h_r);
            //System.out.println(m_r);

            if(H == 0 && M == 0){
              result = A - B;
            }else{
              r = Math.abs(h_r - m_r);
              if(r == 0){
                result = 0;
              }else{
                double cos = Math.cos(Math.toRadians(r));
                double a = Math.pow(A, 2);
                double b = Math.pow(B, 2);
                double tmp = a + b - (2 * A * B * cos);
                result = Math.sqrt(tmp);
              }
            }

            System.out.println(result);
        }

    }
}