import java.util.*;
import java.lang.Math;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
   	int b = sc.nextInt();
    int h = sc.nextInt();
    int m = sc.nextInt();
    double rot;
    double hrot;
    double mrot;
    double ans;
    
   	hrot = h*30 + 30*m/60.0;
    
    mrot = 360*m/60.0;
    
    rot = Math.abs(hrot - mrot);
    if(rot > 180) rot = 360 - rot;
    
    ans = (double)a*a + (double)b*b - 2*a*b*Math.cos(Math.toRadians(rot));
    ans = Math.sqrt(ans);
    
    System.out.println(ans);
  }
} import java.util.*; util.* java import java.lang.Math; Math java.lang public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
   	int b = sc.nextInt();
    int h = sc.nextInt();
    int m = sc.nextInt();
    double rot;
    double hrot;
    double mrot;
    double ans;
    
   	hrot = h*30 + 30*m/60.0;
    
    mrot = 360*m/60.0;
    
    rot = Math.abs(hrot - mrot);
    if(rot > 180) rot = 360 - rot;
    
    ans = (double)a*a + (double)b*b - 2*a*b*Math.cos(Math.toRadians(rot));
    ans = Math.sqrt(ans);
    
    System.out.println(ans);
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
   	int b = sc.nextInt();
    int h = sc.nextInt();
    int m = sc.nextInt();
    double rot;
    double hrot;
    double mrot;
    double ans;
    
   	hrot = h*30 + 30*m/60.0;
    
    mrot = 360*m/60.0;
    
    rot = Math.abs(hrot - mrot);
    if(rot > 180) rot = 360 - rot;
    
    ans = (double)a*a + (double)b*b - 2*a*b*Math.cos(Math.toRadians(rot));
    ans = Math.sqrt(ans);
    
    System.out.println(ans);
  } main {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
   	int b = sc.nextInt();
    int h = sc.nextInt();
    int m = sc.nextInt();
    double rot;
    double hrot;
    double mrot;
    double ans;
    
   	hrot = h*30 + 30*m/60.0;
    
    mrot = 360*m/60.0;
    
    rot = Math.abs(hrot - mrot);
    if(rot > 180) rot = 360 - rot;
    
    ans = (double)a*a + (double)b*b - 2*a*b*Math.cos(Math.toRadians(rot));
    ans = Math.sqrt(ans);
    
    System.out.println(ans);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc int b = sc.nextInt(); b sc.nextInt() sc.nextInt sc int h = sc.nextInt(); h sc.nextInt() sc.nextInt sc int m = sc.nextInt(); m sc.nextInt() sc.nextInt sc double rot; rot double hrot; hrot double mrot; mrot double ans; ans hrot = h*30 + 30*m/60.0 hrot h*30 + 30*m/60.0 h*30 h 30 30*m/60.0 30*m 30 m 60.0 mrot = 360*m/60.0 mrot 360*m/60.0 360*m 360 m 60.0 rot = Math.abs(hrot - mrot) rot Math.abs(hrot - mrot) Math.abs Math hrot - mrot hrot mrot if(rot > 180) rot = 360 - rot; rot > 180 rot 180 rot = 360 - rot rot 360 - rot 360 rot ans = (double)a*a + (double)b*b - 2*a*b*Math.cos(Math.toRadians(rot)) ans (double)a*a + (double)b*b - 2*a*b*Math.cos(Math.toRadians(rot)) (double)a*a + (double)b*b (double)a*a (double)a a (double)b*b (double)b b 2*a*b*Math.cos(Math.toRadians(rot)) b 2*a*b*Math.cos(Math.toRadians(rot)) 2 a b Math.cos(Math.toRadians(rot)) Math.cos Math Math.toRadians(rot) Math.toRadians Math rot ans = Math.sqrt(ans) ans Math.sqrt(ans) Math.sqrt Math ans 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 sc = new Scanner(System.in);
    int a = sc.nextInt();
   	int b = sc.nextInt();
    int h = sc.nextInt();
    int m = sc.nextInt();
    double rot;
    double hrot;
    double mrot;
    double ans;
    
   	hrot = h*30 + 30*m/60.0;
    
    mrot = 360*m/60.0;
    
    rot = Math.abs(hrot - mrot);
    if(rot > 180) rot = 360 - rot;
    
    ans = (double)a*a + (double)b*b - 2*a*b*Math.cos(Math.toRadians(rot));
    ans = Math.sqrt(ans);
    
    System.out.println(ans);
  }
} public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
   	int b = sc.nextInt();
    int h = sc.nextInt();
    int m = sc.nextInt();
    double rot;
    double hrot;
    double mrot;
    double ans;
    
   	hrot = h*30 + 30*m/60.0;
    
    mrot = 360*m/60.0;
    
    rot = Math.abs(hrot - mrot);
    if(rot > 180) rot = 360 - rot;
    
    ans = (double)a*a + (double)b*b - 2*a*b*Math.cos(Math.toRadians(rot));
    ans = Math.sqrt(ans);
    
    System.out.println(ans);
  }
} Main
import java.util.*;
import java.lang.Math;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
   	int b = sc.nextInt();
    int h = sc.nextInt();
    int m = sc.nextInt();
    double rot;
    double hrot;
    double mrot;
    double ans;
    
   	hrot = h*30 + 30*m/60.0;
    
    mrot = 360*m/60.0;
    
    rot = Math.abs(hrot - mrot);
    if(rot > 180) rot = 360 - rot;
    
    ans = (double)a*a + (double)b*b - 2*a*b*Math.cos(Math.toRadians(rot));
    ans = Math.sqrt(ans);
    
    System.out.println(ans);
  }
}
