import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    double A = Double.parseDouble(sc.next());
    double B = Double.parseDouble(sc.next());
    double H = Double.parseDouble(sc.next());
    double M = Double.parseDouble(sc.next());
    double radH = -Math.toRadians((H + M / 60D) * 30D) + 90D;
    double radM = -Math.toRadians(M * 6D) + 90D;
    double hX = A * Math.cos(radH);
    double hY = A * Math.sin(radH);
    double mX = B * Math.cos(radM);
    double mY = B * Math.sin(radM);
    double distance = Math.sqrt((hX - mX) * (hX - mX) + (hY - mY) * (hY - mY));
    System.out.println(distance);
  }
} import java.util.*; util.* java public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    double A = Double.parseDouble(sc.next());
    double B = Double.parseDouble(sc.next());
    double H = Double.parseDouble(sc.next());
    double M = Double.parseDouble(sc.next());
    double radH = -Math.toRadians((H + M / 60D) * 30D) + 90D;
    double radM = -Math.toRadians(M * 6D) + 90D;
    double hX = A * Math.cos(radH);
    double hY = A * Math.sin(radH);
    double mX = B * Math.cos(radM);
    double mY = B * Math.sin(radM);
    double distance = Math.sqrt((hX - mX) * (hX - mX) + (hY - mY) * (hY - mY));
    System.out.println(distance);
  }
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    double A = Double.parseDouble(sc.next());
    double B = Double.parseDouble(sc.next());
    double H = Double.parseDouble(sc.next());
    double M = Double.parseDouble(sc.next());
    double radH = -Math.toRadians((H + M / 60D) * 30D) + 90D;
    double radM = -Math.toRadians(M * 6D) + 90D;
    double hX = A * Math.cos(radH);
    double hY = A * Math.sin(radH);
    double mX = B * Math.cos(radM);
    double mY = B * Math.sin(radM);
    double distance = Math.sqrt((hX - mX) * (hX - mX) + (hY - mY) * (hY - mY));
    System.out.println(distance);
  } main {
    Scanner sc = new Scanner(System.in);
    double A = Double.parseDouble(sc.next());
    double B = Double.parseDouble(sc.next());
    double H = Double.parseDouble(sc.next());
    double M = Double.parseDouble(sc.next());
    double radH = -Math.toRadians((H + M / 60D) * 30D) + 90D;
    double radM = -Math.toRadians(M * 6D) + 90D;
    double hX = A * Math.cos(radH);
    double hY = A * Math.sin(radH);
    double mX = B * Math.cos(radM);
    double mY = B * Math.sin(radM);
    double distance = Math.sqrt((hX - mX) * (hX - mX) + (hY - mY) * (hY - mY));
    System.out.println(distance);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) double A = Double.parseDouble(sc.next()); A Double.parseDouble(sc.next()) Double.parseDouble Double sc.next() sc.next sc double B = Double.parseDouble(sc.next()); B Double.parseDouble(sc.next()) Double.parseDouble Double sc.next() sc.next sc double H = Double.parseDouble(sc.next()); H Double.parseDouble(sc.next()) Double.parseDouble Double sc.next() sc.next sc double M = Double.parseDouble(sc.next()); M Double.parseDouble(sc.next()) Double.parseDouble Double sc.next() sc.next sc double radH = -Math.toRadians((H + M / 60D) * 30D) + 90D; radH -Math.toRadians((H + M / 60D) * 30D) + 90D -Math.toRadians((H + M / 60D) * 30D) Math.toRadians((H + M / 60D) * 30D) Math.toRadians Math (H + M / 60D) * 30D (H + M / 60D) H M / 60D M 60D 30D 90D double radM = -Math.toRadians(M * 6D) + 90D; radM -Math.toRadians(M * 6D) + 90D -Math.toRadians(M * 6D) Math.toRadians(M * 6D) Math.toRadians Math M * 6D M 6D 90D double hX = A * Math.cos(radH); hX A * Math.cos(radH) A Math.cos(radH) Math.cos Math radH double hY = A * Math.sin(radH); hY A * Math.sin(radH) A Math.sin(radH) Math.sin Math radH double mX = B * Math.cos(radM); mX B * Math.cos(radM) B Math.cos(radM) Math.cos Math radM double mY = B * Math.sin(radM); mY B * Math.sin(radM) B Math.sin(radM) Math.sin Math radM double distance = Math.sqrt((hX - mX) * (hX - mX) + (hY - mY) * (hY - mY)); distance Math.sqrt((hX - mX) * (hX - mX) + (hY - mY) * (hY - mY)) Math.sqrt Math (hX - mX) * (hX - mX) + (hY - mY) * (hY - mY) (hX - mX) * (hX - mX) (hX - mX) hX mX (hX - mX) hX mX (hY - mY) * (hY - mY) (hY - mY) hY mY (hY - mY) hY mY System.out.println(distance) System.out.println System.out System System.out distance String[] args args public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    double A = Double.parseDouble(sc.next());
    double B = Double.parseDouble(sc.next());
    double H = Double.parseDouble(sc.next());
    double M = Double.parseDouble(sc.next());
    double radH = -Math.toRadians((H + M / 60D) * 30D) + 90D;
    double radM = -Math.toRadians(M * 6D) + 90D;
    double hX = A * Math.cos(radH);
    double hY = A * Math.sin(radH);
    double mX = B * Math.cos(radM);
    double mY = B * Math.sin(radM);
    double distance = Math.sqrt((hX - mX) * (hX - mX) + (hY - mY) * (hY - mY));
    System.out.println(distance);
  }
} public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    double A = Double.parseDouble(sc.next());
    double B = Double.parseDouble(sc.next());
    double H = Double.parseDouble(sc.next());
    double M = Double.parseDouble(sc.next());
    double radH = -Math.toRadians((H + M / 60D) * 30D) + 90D;
    double radM = -Math.toRadians(M * 6D) + 90D;
    double hX = A * Math.cos(radH);
    double hY = A * Math.sin(radH);
    double mX = B * Math.cos(radM);
    double mY = B * Math.sin(radM);
    double distance = Math.sqrt((hX - mX) * (hX - mX) + (hY - mY) * (hY - mY));
    System.out.println(distance);
  }
} Main
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    double A = Double.parseDouble(sc.next());
    double B = Double.parseDouble(sc.next());
    double H = Double.parseDouble(sc.next());
    double M = Double.parseDouble(sc.next());
    double radH = -Math.toRadians((H + M / 60D) * 30D) + 90D;
    double radM = -Math.toRadians(M * 6D) + 90D;
    double hX = A * Math.cos(radH);
    double hY = A * Math.sin(radH);
    double mX = B * Math.cos(radM);
    double mY = B * Math.sin(radM);
    double distance = Math.sqrt((hX - mX) * (hX - mX) + (hY - mY) * (hY - mY));
    System.out.println(distance);
  }
}