
import java.util.*;

class Main {


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double A = sc.nextInt();
		double B = sc.nextInt();
		double H = sc.nextInt();
		double M = sc.nextInt();
		
		double radH = 2*Math.PI*(H/12 + M/60/12);
		double radM = 2*Math.PI* M/60;
		double x1 = (double)A*Math.cos(radH), y1 = A*Math.sin(radH);
		double x2 = (double)B*Math.cos(radM), y2 = B*Math.sin(radM);
		double dx = x1 - x2, dy = y1- y2;
		double ansans = Math.pow(dx, 2) + Math.pow(dy,2);
		double ans = Math.sqrt(ansans);
		System.out.print(ans);
		
	}

}

 import java.util.*; util.* java class Main {


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double A = sc.nextInt();
		double B = sc.nextInt();
		double H = sc.nextInt();
		double M = sc.nextInt();
		
		double radH = 2*Math.PI*(H/12 + M/60/12);
		double radM = 2*Math.PI* M/60;
		double x1 = (double)A*Math.cos(radH), y1 = A*Math.sin(radH);
		double x2 = (double)B*Math.cos(radM), y2 = B*Math.sin(radM);
		double dx = x1 - x2, dy = y1- y2;
		double ansans = Math.pow(dx, 2) + Math.pow(dy,2);
		double ans = Math.sqrt(ansans);
		System.out.print(ans);
		
	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double A = sc.nextInt();
		double B = sc.nextInt();
		double H = sc.nextInt();
		double M = sc.nextInt();
		
		double radH = 2*Math.PI*(H/12 + M/60/12);
		double radM = 2*Math.PI* M/60;
		double x1 = (double)A*Math.cos(radH), y1 = A*Math.sin(radH);
		double x2 = (double)B*Math.cos(radM), y2 = B*Math.sin(radM);
		double dx = x1 - x2, dy = y1- y2;
		double ansans = Math.pow(dx, 2) + Math.pow(dy,2);
		double ans = Math.sqrt(ansans);
		System.out.print(ans);
		
	} main {
		Scanner sc = new Scanner(System.in);
		double A = sc.nextInt();
		double B = sc.nextInt();
		double H = sc.nextInt();
		double M = sc.nextInt();
		
		double radH = 2*Math.PI*(H/12 + M/60/12);
		double radM = 2*Math.PI* M/60;
		double x1 = (double)A*Math.cos(radH), y1 = A*Math.sin(radH);
		double x2 = (double)B*Math.cos(radM), y2 = B*Math.sin(radM);
		double dx = x1 - x2, dy = y1- y2;
		double ansans = Math.pow(dx, 2) + Math.pow(dy,2);
		double ans = Math.sqrt(ansans);
		System.out.print(ans);
		
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) double A = sc.nextInt(); A sc.nextInt() sc.nextInt sc double B = sc.nextInt(); B sc.nextInt() sc.nextInt sc double H = sc.nextInt(); H sc.nextInt() sc.nextInt sc double M = sc.nextInt(); M sc.nextInt() sc.nextInt sc double radH = 2*Math.PI*(H/12 + M/60/12); radH 2*Math.PI*(H/12 + M/60/12) 2*Math.PI*(H/12 + M/60/12) 2 Math.PI Math Math.PI (H/12 + M/60/12) H/12 H 12 M/60/12 M/60/12 M 60 12 double radM = 2*Math.PI* M/60; radM 2*Math.PI* M/60 2*Math.PI* M 2*Math.PI* M 2 Math.PI Math Math.PI M 60 double x1 = (double)A*Math.cos(radH) x1 (double)A*Math.cos(radH) (double)A Math.cos(radH) Math.cos Math radH y1 = A*Math.sin(radH); y1 A*Math.sin(radH) A Math.sin(radH) Math.sin Math radH double x2 = (double)B*Math.cos(radM) x2 (double)B*Math.cos(radM) (double)B Math.cos(radM) Math.cos Math radM y2 = B*Math.sin(radM); y2 B*Math.sin(radM) B Math.sin(radM) Math.sin Math radM double dx = x1 - x2 dx x1 - x2 x1 x2 dy = y1- y2; dy y1- y2 y1 y2 double ansans = Math.pow(dx, 2) + Math.pow(dy,2); ansans Math.pow(dx, 2) + Math.pow(dy,2) Math.pow(dx, 2) Math.pow Math dx 2 Math.pow(dy,2) Math.pow Math dy 2 double ans = Math.sqrt(ansans); ans Math.sqrt(ansans) Math.sqrt Math ansans System.out.print(ans) System.out.print System.out System System.out ans String[] args args

import java.util.*;

class Main {


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double A = sc.nextInt();
		double B = sc.nextInt();
		double H = sc.nextInt();
		double M = sc.nextInt();
		
		double radH = 2*Math.PI*(H/12 + M/60/12);
		double radM = 2*Math.PI* M/60;
		double x1 = (double)A*Math.cos(radH), y1 = A*Math.sin(radH);
		double x2 = (double)B*Math.cos(radM), y2 = B*Math.sin(radM);
		double dx = x1 - x2, dy = y1- y2;
		double ansans = Math.pow(dx, 2) + Math.pow(dy,2);
		double ans = Math.sqrt(ansans);
		System.out.print(ans);
		
	}

}


