import java.util.*;

class Point {
  double x;
  double y;

  public Point(double deg, double r) {
    double rad = deg * Math.PI / 180.0;
    x = Math.cos(rad) * r;
    y = Math.sin(rad) * r;
    // System.out.printf("[%f, %f]\n", x, y);
  }

  public double getX() {
    return x;
  }

  public double getY() {
    return y;
  }

  public double distance(Point b) {
    double c = Math.pow(x - b.getX(), 2);
    double d = Math.pow(y - b.getY(), 2);
    return Math.sqrt(c + d);
  }

  public void show() {
    System.out.printf("[%f, %f]\n", x, y);
  }
}

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    try {
      double a = scanner.nextDouble();
      double b = scanner.nextDouble();
      double h = scanner.nextDouble();
      double m = scanner.nextDouble();

      // 長針
      Point bigHand = new Point(m * 6.0, b);

      // 短針
      Point smallHand = new Point(h * 30.0 + m * 0.5, a);

      double ans = bigHand.distance(smallHand);
      System.out.println(ans);
    } finally {
      scanner.close();
    }
  }
} import java.util.*; util.* java class Point {
  double x;
  double y;

  public Point(double deg, double r) {
    double rad = deg * Math.PI / 180.0;
    x = Math.cos(rad) * r;
    y = Math.sin(rad) * r;
    // System.out.printf("[%f, %f]\n", x, y);
  }

  public double getX() {
    return x;
  }

  public double getY() {
    return y;
  }

  public double distance(Point b) {
    double c = Math.pow(x - b.getX(), 2);
    double d = Math.pow(y - b.getY(), 2);
    return Math.sqrt(c + d);
  }

  public void show() {
    System.out.printf("[%f, %f]\n", x, y);
  }
} Point double x; x double y; y public Point(double deg, double r) {
    double rad = deg * Math.PI / 180.0;
    x = Math.cos(rad) * r;
    y = Math.sin(rad) * r;
    // System.out.printf("[%f, %f]\n", x, y);
  } Point {
    double rad = deg * Math.PI / 180.0;
    x = Math.cos(rad) * r;
    y = Math.sin(rad) * r;
    // System.out.printf("[%f, %f]\n", x, y);
  } double rad = deg * Math.PI / 180.0; rad deg * Math.PI / 180.0 deg * Math.PI deg Math.PI Math Math.PI 180.0 x = Math.cos(rad) * r x Math.cos(rad) * r Math.cos(rad) Math.cos Math rad r y = Math.sin(rad) * r y Math.sin(rad) * r Math.sin(rad) Math.sin Math rad r double deg deg double r r public double getX() {
    return x;
  } getX {
    return x;
  } return x; x public double getY() {
    return y;
  } getY {
    return y;
  } return y; y public double distance(Point b) {
    double c = Math.pow(x - b.getX(), 2);
    double d = Math.pow(y - b.getY(), 2);
    return Math.sqrt(c + d);
  } distance {
    double c = Math.pow(x - b.getX(), 2);
    double d = Math.pow(y - b.getY(), 2);
    return Math.sqrt(c + d);
  } double c = Math.pow(x - b.getX(), 2); c Math.pow(x - b.getX(), 2) Math.pow Math x - b.getX() x b.getX() b.getX b 2 double d = Math.pow(y - b.getY(), 2); d Math.pow(y - b.getY(), 2) Math.pow Math y - b.getY() y b.getY() b.getY b 2 return Math.sqrt(c + d); Math.sqrt(c + d) Math.sqrt Math c + d c d Point b b public void show() {
    System.out.printf("[%f, %f]\n", x, y);
  } show {
    System.out.printf("[%f, %f]\n", x, y);
  } System.out.printf("[%f, %f]\n", x, y) System.out.printf System.out System System.out "[%f, %f]\n" x y public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    try {
      double a = scanner.nextDouble();
      double b = scanner.nextDouble();
      double h = scanner.nextDouble();
      double m = scanner.nextDouble();

      // 長針
      Point bigHand = new Point(m * 6.0, b);

      // 短針
      Point smallHand = new Point(h * 30.0 + m * 0.5, a);

      double ans = bigHand.distance(smallHand);
      System.out.println(ans);
    } finally {
      scanner.close();
    }
  }
} Main public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    try {
      double a = scanner.nextDouble();
      double b = scanner.nextDouble();
      double h = scanner.nextDouble();
      double m = scanner.nextDouble();

      // 長針
      Point bigHand = new Point(m * 6.0, b);

      // 短針
      Point smallHand = new Point(h * 30.0 + m * 0.5, a);

      double ans = bigHand.distance(smallHand);
      System.out.println(ans);
    } finally {
      scanner.close();
    }
  } main {
    Scanner scanner = new Scanner(System.in);
    try {
      double a = scanner.nextDouble();
      double b = scanner.nextDouble();
      double h = scanner.nextDouble();
      double m = scanner.nextDouble();

      // 長針
      Point bigHand = new Point(m * 6.0, b);

      // 短針
      Point smallHand = new Point(h * 30.0 + m * 0.5, a);

      double ans = bigHand.distance(smallHand);
      System.out.println(ans);
    } finally {
      scanner.close();
    }
  } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) try {
      double a = scanner.nextDouble();
      double b = scanner.nextDouble();
      double h = scanner.nextDouble();
      double m = scanner.nextDouble();

      // 長針
      Point bigHand = new Point(m * 6.0, b);

      // 短針
      Point smallHand = new Point(h * 30.0 + m * 0.5, a);

      double ans = bigHand.distance(smallHand);
      System.out.println(ans);
    } finally {
      scanner.close();
    } {
      scanner.close();
    } scanner.close() scanner.close scanner {
      double a = scanner.nextDouble();
      double b = scanner.nextDouble();
      double h = scanner.nextDouble();
      double m = scanner.nextDouble();

      // 長針
      Point bigHand = new Point(m * 6.0, b);

      // 短針
      Point smallHand = new Point(h * 30.0 + m * 0.5, a);

      double ans = bigHand.distance(smallHand);
      System.out.println(ans);
    } double a = scanner.nextDouble(); a scanner.nextDouble() scanner.nextDouble scanner double b = scanner.nextDouble(); b scanner.nextDouble() scanner.nextDouble scanner double h = scanner.nextDouble(); h scanner.nextDouble() scanner.nextDouble scanner double m = scanner.nextDouble(); m scanner.nextDouble() scanner.nextDouble scanner Point bigHand = new Point(m * 6.0, b); bigHand new Point(m * 6.0, b) Point smallHand = new Point(h * 30.0 + m * 0.5, a); smallHand new Point(h * 30.0 + m * 0.5, a) double ans = bigHand.distance(smallHand); ans bigHand.distance(smallHand) bigHand.distance bigHand smallHand 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) {
    Scanner scanner = new Scanner(System.in);
    try {
      double a = scanner.nextDouble();
      double b = scanner.nextDouble();
      double h = scanner.nextDouble();
      double m = scanner.nextDouble();

      // 長針
      Point bigHand = new Point(m * 6.0, b);

      // 短針
      Point smallHand = new Point(h * 30.0 + m * 0.5, a);

      double ans = bigHand.distance(smallHand);
      System.out.println(ans);
    } finally {
      scanner.close();
    }
  }
} public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    try {
      double a = scanner.nextDouble();
      double b = scanner.nextDouble();
      double h = scanner.nextDouble();
      double m = scanner.nextDouble();

      // 長針
      Point bigHand = new Point(m * 6.0, b);

      // 短針
      Point smallHand = new Point(h * 30.0 + m * 0.5, a);

      double ans = bigHand.distance(smallHand);
      System.out.println(ans);
    } finally {
      scanner.close();
    }
  }
} Main
import java.util.*;

class Point {
  double x;
  double y;

  public Point(double deg, double r) {
    double rad = deg * Math.PI / 180.0;
    x = Math.cos(rad) * r;
    y = Math.sin(rad) * r;
    // System.out.printf("[%f, %f]\n", x, y);
  }

  public double getX() {
    return x;
  }

  public double getY() {
    return y;
  }

  public double distance(Point b) {
    double c = Math.pow(x - b.getX(), 2);
    double d = Math.pow(y - b.getY(), 2);
    return Math.sqrt(c + d);
  }

  public void show() {
    System.out.printf("[%f, %f]\n", x, y);
  }
}

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    try {
      double a = scanner.nextDouble();
      double b = scanner.nextDouble();
      double h = scanner.nextDouble();
      double m = scanner.nextDouble();

      // 長針
      Point bigHand = new Point(m * 6.0, b);

      // 短針
      Point smallHand = new Point(h * 30.0 + m * 0.5, a);

      double ans = bigHand.distance(smallHand);
      System.out.println(ans);
    } finally {
      scanner.close();
    }
  }
}