import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    Scanner in = new Scanner(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    B solver = new B();
    solver.solve(1, in, out);
    out.close();
  }

  static class B {
    public void solve(int testNumber, Scanner in, PrintWriter out) {
      int A = in.nextInt();
      int B = in.nextInt();
      int H = in.nextInt();
      int M = in.nextInt();

      double angleA = (H * 60 + M) * Math.PI / 360;
      double angleB = (M * Math.PI) / 30;
      double C = A * A + B * B - (2 * A * B * Math.cos(Math.abs(angleA - angleB)));
      System.out.println(Math.sqrt(C));
    }

  }
}
 import java.io.OutputStream; OutputStream java.io import java.io.IOException; IOException java.io import java.io.InputStream; InputStream java.io import java.io.PrintWriter; PrintWriter java.io import java.io.PrintStream; PrintStream java.io import java.util.Scanner; Scanner java.util public class Main {
  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    Scanner in = new Scanner(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    B solver = new B();
    solver.solve(1, in, out);
    out.close();
  }

  static class B {
    public void solve(int testNumber, Scanner in, PrintWriter out) {
      int A = in.nextInt();
      int B = in.nextInt();
      int H = in.nextInt();
      int M = in.nextInt();

      double angleA = (H * 60 + M) * Math.PI / 360;
      double angleB = (M * Math.PI) / 30;
      double C = A * A + B * B - (2 * A * B * Math.cos(Math.abs(angleA - angleB)));
      System.out.println(Math.sqrt(C));
    }

  }
} Main public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    Scanner in = new Scanner(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    B solver = new B();
    solver.solve(1, in, out);
    out.close();
  } main {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    Scanner in = new Scanner(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    B solver = new B();
    solver.solve(1, in, out);
    out.close();
  } InputStream inputStream = System.in; inputStream System.in System System.in OutputStream outputStream = System.out; outputStream System.out System System.out Scanner in = new Scanner(inputStream); in new Scanner(inputStream) PrintWriter out = new PrintWriter(outputStream); out new PrintWriter(outputStream) B solver = new B(); solver new B() solver.solve(1, in, out) solver.solve solver 1 in out out.close() out.close out String[] args args static class B {
    public void solve(int testNumber, Scanner in, PrintWriter out) {
      int A = in.nextInt();
      int B = in.nextInt();
      int H = in.nextInt();
      int M = in.nextInt();

      double angleA = (H * 60 + M) * Math.PI / 360;
      double angleB = (M * Math.PI) / 30;
      double C = A * A + B * B - (2 * A * B * Math.cos(Math.abs(angleA - angleB)));
      System.out.println(Math.sqrt(C));
    }

  } B public void solve(int testNumber, Scanner in, PrintWriter out) {
      int A = in.nextInt();
      int B = in.nextInt();
      int H = in.nextInt();
      int M = in.nextInt();

      double angleA = (H * 60 + M) * Math.PI / 360;
      double angleB = (M * Math.PI) / 30;
      double C = A * A + B * B - (2 * A * B * Math.cos(Math.abs(angleA - angleB)));
      System.out.println(Math.sqrt(C));
    } solve {
      int A = in.nextInt();
      int B = in.nextInt();
      int H = in.nextInt();
      int M = in.nextInt();

      double angleA = (H * 60 + M) * Math.PI / 360;
      double angleB = (M * Math.PI) / 30;
      double C = A * A + B * B - (2 * A * B * Math.cos(Math.abs(angleA - angleB)));
      System.out.println(Math.sqrt(C));
    } int A = in.nextInt(); A in.nextInt() in.nextInt in int B = in.nextInt(); B in.nextInt() in.nextInt in int H = in.nextInt(); H in.nextInt() in.nextInt in int M = in.nextInt(); M in.nextInt() in.nextInt in double angleA = (H * 60 + M) * Math.PI / 360; angleA (H * 60 + M) * Math.PI / 360 (H * 60 + M) * Math.PI (H * 60 + M) H * 60 H 60 M Math.PI Math Math.PI 360 double angleB = (M * Math.PI) / 30; angleB (M * Math.PI) / 30 (M * Math.PI) M Math.PI Math Math.PI 30 double C = A * A + B * B - (2 * A * B * Math.cos(Math.abs(angleA - angleB))); C A * A + B * B - (2 * A * B * Math.cos(Math.abs(angleA - angleB))) A * A + B * B A * A A A B * B B B (2 * A * B * Math.cos(Math.abs(angleA - angleB))) B 2 * A * B * Math.cos(Math.abs(angleA - angleB)) 2 A B Math.cos(Math.abs(angleA - angleB)) Math.cos Math Math.abs(angleA - angleB) Math.abs Math angleA - angleB angleA angleB System.out.println(Math.sqrt(C)) System.out.println System.out System System.out Math.sqrt(C) Math.sqrt Math C int testNumber testNumber Scanner in in PrintWriter out out public class Main {
  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    Scanner in = new Scanner(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    B solver = new B();
    solver.solve(1, in, out);
    out.close();
  }

  static class B {
    public void solve(int testNumber, Scanner in, PrintWriter out) {
      int A = in.nextInt();
      int B = in.nextInt();
      int H = in.nextInt();
      int M = in.nextInt();

      double angleA = (H * 60 + M) * Math.PI / 360;
      double angleB = (M * Math.PI) / 30;
      double C = A * A + B * B - (2 * A * B * Math.cos(Math.abs(angleA - angleB)));
      System.out.println(Math.sqrt(C));
    }

  }
} public class Main {
  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    Scanner in = new Scanner(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    B solver = new B();
    solver.solve(1, in, out);
    out.close();
  }

  static class B {
    public void solve(int testNumber, Scanner in, PrintWriter out) {
      int A = in.nextInt();
      int B = in.nextInt();
      int H = in.nextInt();
      int M = in.nextInt();

      double angleA = (H * 60 + M) * Math.PI / 360;
      double angleB = (M * Math.PI) / 30;
      double C = A * A + B * B - (2 * A * B * Math.cos(Math.abs(angleA - angleB)));
      System.out.println(Math.sqrt(C));
    }

  }
} Main
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    Scanner in = new Scanner(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    B solver = new B();
    solver.solve(1, in, out);
    out.close();
  }

  static class B {
    public void solve(int testNumber, Scanner in, PrintWriter out) {
      int A = in.nextInt();
      int B = in.nextInt();
      int H = in.nextInt();
      int M = in.nextInt();

      double angleA = (H * 60 + M) * Math.PI / 360;
      double angleB = (M * Math.PI) / 30;
      double C = A * A + B * B - (2 * A * B * Math.cos(Math.abs(angleA - angleB)));
      System.out.println(Math.sqrt(C));
    }

  }
}

