import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {

  static double a, b, h, m;

  public static void main(String[] args) throws Exception {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter out = new PrintWriter(System.out);

    String[] in = br.readLine().split(" ");
    a = Double.parseDouble(in[0]);
    b = Double.parseDouble(in[1]);
    h = Double.parseDouble(in[2]);
    m = Double.parseDouble(in[3]);

    br.close();

    double ang = Math.PI * Math.abs(30.0 * h + 0.5 * m - 6.0 * m) / 180.0;

    out.println(Math.sqrt(a * a + b * b - 2.0 * a * b * Math.cos(ang)));

    out.flush();
  }
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.PrintWriter; PrintWriter java.io public class Main {

  static double a, b, h, m;

  public static void main(String[] args) throws Exception {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter out = new PrintWriter(System.out);

    String[] in = br.readLine().split(" ");
    a = Double.parseDouble(in[0]);
    b = Double.parseDouble(in[1]);
    h = Double.parseDouble(in[2]);
    m = Double.parseDouble(in[3]);

    br.close();

    double ang = Math.PI * Math.abs(30.0 * h + 0.5 * m - 6.0 * m) / 180.0;

    out.println(Math.sqrt(a * a + b * b - 2.0 * a * b * Math.cos(ang)));

    out.flush();
  }
} Main static double a a b b h h m; m public static void main(String[] args) throws Exception {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter out = new PrintWriter(System.out);

    String[] in = br.readLine().split(" ");
    a = Double.parseDouble(in[0]);
    b = Double.parseDouble(in[1]);
    h = Double.parseDouble(in[2]);
    m = Double.parseDouble(in[3]);

    br.close();

    double ang = Math.PI * Math.abs(30.0 * h + 0.5 * m - 6.0 * m) / 180.0;

    out.println(Math.sqrt(a * a + b * b - 2.0 * a * b * Math.cos(ang)));

    out.flush();
  } main {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter out = new PrintWriter(System.out);

    String[] in = br.readLine().split(" ");
    a = Double.parseDouble(in[0]);
    b = Double.parseDouble(in[1]);
    h = Double.parseDouble(in[2]);
    m = Double.parseDouble(in[3]);

    br.close();

    double ang = Math.PI * Math.abs(30.0 * h + 0.5 * m - 6.0 * m) / 180.0;

    out.println(Math.sqrt(a * a + b * b - 2.0 * a * b * Math.cos(ang)));

    out.flush();
  } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) String[] in = br.readLine().split(" "); in br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " a = Double.parseDouble(in[0]) a Double.parseDouble(in[0]) Double.parseDouble Double in[0] in 0 b = Double.parseDouble(in[1]) b Double.parseDouble(in[1]) Double.parseDouble Double in[1] in 1 h = Double.parseDouble(in[2]) h Double.parseDouble(in[2]) Double.parseDouble Double in[2] in 2 m = Double.parseDouble(in[3]) m Double.parseDouble(in[3]) Double.parseDouble Double in[3] in 3 br.close() br.close br double ang = Math.PI * Math.abs(30.0 * h + 0.5 * m - 6.0 * m) / 180.0; ang Math.PI * Math.abs(30.0 * h + 0.5 * m - 6.0 * m) / 180.0 Math.PI * Math.abs(30.0 * h + 0.5 * m - 6.0 * m) Math.PI Math Math.PI Math.abs(30.0 * h + 0.5 * m - 6.0 * m) Math.abs Math 30.0 * h + 0.5 * m - 6.0 * m 30.0 * h + 0.5 * m 30.0 * h 30.0 h 0.5 * m 0.5 m 6.0 * m 6.0 m 180.0 out.println(Math.sqrt(a * a + b * b - 2.0 * a * b * Math.cos(ang))) out.println out Math.sqrt(a * a + b * b - 2.0 * a * b * Math.cos(ang)) Math.sqrt Math a * a + b * b - 2.0 * a * b * Math.cos(ang) a * a + b * b a * a a a b * b b b 2.0 * a * b * Math.cos(ang) b 2.0 * a * b * Math.cos(ang) 2.0 a b Math.cos(ang) Math.cos Math ang out.flush() out.flush out String[] args args public class Main {

  static double a, b, h, m;

  public static void main(String[] args) throws Exception {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter out = new PrintWriter(System.out);

    String[] in = br.readLine().split(" ");
    a = Double.parseDouble(in[0]);
    b = Double.parseDouble(in[1]);
    h = Double.parseDouble(in[2]);
    m = Double.parseDouble(in[3]);

    br.close();

    double ang = Math.PI * Math.abs(30.0 * h + 0.5 * m - 6.0 * m) / 180.0;

    out.println(Math.sqrt(a * a + b * b - 2.0 * a * b * Math.cos(ang)));

    out.flush();
  }
} public class Main {

  static double a, b, h, m;

  public static void main(String[] args) throws Exception {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter out = new PrintWriter(System.out);

    String[] in = br.readLine().split(" ");
    a = Double.parseDouble(in[0]);
    b = Double.parseDouble(in[1]);
    h = Double.parseDouble(in[2]);
    m = Double.parseDouble(in[3]);

    br.close();

    double ang = Math.PI * Math.abs(30.0 * h + 0.5 * m - 6.0 * m) / 180.0;

    out.println(Math.sqrt(a * a + b * b - 2.0 * a * b * Math.cos(ang)));

    out.flush();
  }
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {

  static double a, b, h, m;

  public static void main(String[] args) throws Exception {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter out = new PrintWriter(System.out);

    String[] in = br.readLine().split(" ");
    a = Double.parseDouble(in[0]);
    b = Double.parseDouble(in[1]);
    h = Double.parseDouble(in[2]);
    m = Double.parseDouble(in[3]);

    br.close();

    double ang = Math.PI * Math.abs(30.0 * h + 0.5 * m - 6.0 * m) / 180.0;

    out.println(Math.sqrt(a * a + b * b - 2.0 * a * b * Math.cos(ang)));

    out.flush();
  }
}
