import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    double A = sc.nextDouble();
    double B = sc.nextDouble();
    double H = sc.nextDouble();
    double M = sc.nextDouble();
    double xShort;
    double yShort;
    double degreeShort = 90 - (30 * H) - (30 * M / 60); // 時針は分針のぶんもちょっぴり動く
    double xLong;
    double yLong;
    double degreeLong = 90 - (6 * M);

    double radianShort = degreeShort * Math.PI / 180;
    yShort = Math.sin(radianShort) * A;
    xShort = Math.cos(radianShort) * A;

    double radianLong = degreeLong * Math.PI / 180;
    yLong = Math.sin(radianLong) * B;
    xLong = Math.cos(radianLong) * B;

    double distance =
        Math.sqrt((xLong - xShort) * (xLong - xShort) + (yLong - yShort) * (yLong - yShort));
    System.out.println(distance);
  }
}

/tmp/hf-datasets-cache/medium/datasets/42704881117311-config-parquet-and-info-qiankunmu-Project_CodeNet-896c9d36/hub/datasets--qiankunmu--Project_CodeNet_Python800_and_Java250/snapshots/c899fde44a77ba1cc14973ed3de064e4ff3aadc7/Project_CodeNet_Java250.tar.gz