import java.util.*;
import java.math.*;

public class Main {
    static final int MOD = 1_000_000_007; // 10^9+7
    // static final int MAX = 2_147_483_646; // intの最大値
    static final int INF = 1_000_000_000; // 10^9
    static final int MAX = 10_000_000;
    static long[] fact = new long[100];

    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();
        h *= 30;
        m*=6;
        //System.out.println(h+" "+m);
        //何度
        double rad = h-m;
        rad+=(double)m/12;
        if(rad>180)rad -=360;
        if(rad<0)rad*=-1;
        //System.out.println(rad);
        //System.out.println(Math.acos(rad));
        rad = rad*Math.PI/180;
        
        //rad =Math.PI*80/180;
        //System.out.println(rad);
        //System.out.println(Math.cos(rad));
        double ans = a*a +b*b - 2*a*b*Math.cos(rad);
        //System.out.println(ans);
        System.out.println(Math.sqrt(ans));
    }
} import java.util.*; util.* java import java.math.*; math.* java public class Main {
    static final int MOD = 1_000_000_007; // 10^9+7
    // static final int MAX = 2_147_483_646; // intの最大値
    static final int INF = 1_000_000_000; // 10^9
    static final int MAX = 10_000_000;
    static long[] fact = new long[100];

    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();
        h *= 30;
        m*=6;
        //System.out.println(h+" "+m);
        //何度
        double rad = h-m;
        rad+=(double)m/12;
        if(rad>180)rad -=360;
        if(rad<0)rad*=-1;
        //System.out.println(rad);
        //System.out.println(Math.acos(rad));
        rad = rad*Math.PI/180;
        
        //rad =Math.PI*80/180;
        //System.out.println(rad);
        //System.out.println(Math.cos(rad));
        double ans = a*a +b*b - 2*a*b*Math.cos(rad);
        //System.out.println(ans);
        System.out.println(Math.sqrt(ans));
    }
} Main static final int MOD = 1_000_000_007; // 10^9+7 MOD 1_000_000_007 // static final int MAX = 2_147_483_646; // intの最大値
    static final int INF = 1_000_000_000; // 10^9 INF 1_000_000_000 static final int MAX = 10_000_000; MAX 10_000_000 static long[] fact = new long[100]; fact new long[100] 100 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();
        h *= 30;
        m*=6;
        //System.out.println(h+" "+m);
        //何度
        double rad = h-m;
        rad+=(double)m/12;
        if(rad>180)rad -=360;
        if(rad<0)rad*=-1;
        //System.out.println(rad);
        //System.out.println(Math.acos(rad));
        rad = rad*Math.PI/180;
        
        //rad =Math.PI*80/180;
        //System.out.println(rad);
        //System.out.println(Math.cos(rad));
        double ans = a*a +b*b - 2*a*b*Math.cos(rad);
        //System.out.println(ans);
        System.out.println(Math.sqrt(ans));
    } main {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        int m = sc.nextInt();
        h *= 30;
        m*=6;
        //System.out.println(h+" "+m);
        //何度
        double rad = h-m;
        rad+=(double)m/12;
        if(rad>180)rad -=360;
        if(rad<0)rad*=-1;
        //System.out.println(rad);
        //System.out.println(Math.acos(rad));
        rad = rad*Math.PI/180;
        
        //rad =Math.PI*80/180;
        //System.out.println(rad);
        //System.out.println(Math.cos(rad));
        double ans = a*a +b*b - 2*a*b*Math.cos(rad);
        //System.out.println(ans);
        System.out.println(Math.sqrt(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 h *= 30 h 30 m*=6 m 6 double rad = h-m; rad h-m h m rad+=(double)m/12 rad (double)m/12 (double)m 12 if(rad>180)rad -=360; rad>180 rad 180 rad -=360 rad 360 if(rad<0)rad*=-1; rad<0 rad 0 rad*=-1 rad -1 1 rad = rad*Math.PI/180 rad rad*Math.PI/180 rad*Math.PI rad Math.PI Math Math.PI 180 double ans = a*a +b*b - 2*a*b*Math.cos(rad); ans a*a +b*b - 2*a*b*Math.cos(rad) a*a +b*b a*a a a b*b b b 2*a*b*Math.cos(rad) b 2*a*b*Math.cos(rad) 2 a b Math.cos(rad) Math.cos Math rad System.out.println(Math.sqrt(ans)) System.out.println System.out System System.out Math.sqrt(ans) Math.sqrt Math ans String args[] args public class Main {
    static final int MOD = 1_000_000_007; // 10^9+7
    // static final int MAX = 2_147_483_646; // intの最大値
    static final int INF = 1_000_000_000; // 10^9
    static final int MAX = 10_000_000;
    static long[] fact = new long[100];

    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();
        h *= 30;
        m*=6;
        //System.out.println(h+" "+m);
        //何度
        double rad = h-m;
        rad+=(double)m/12;
        if(rad>180)rad -=360;
        if(rad<0)rad*=-1;
        //System.out.println(rad);
        //System.out.println(Math.acos(rad));
        rad = rad*Math.PI/180;
        
        //rad =Math.PI*80/180;
        //System.out.println(rad);
        //System.out.println(Math.cos(rad));
        double ans = a*a +b*b - 2*a*b*Math.cos(rad);
        //System.out.println(ans);
        System.out.println(Math.sqrt(ans));
    }
} public class Main {
    static final int MOD = 1_000_000_007; // 10^9+7
    // static final int MAX = 2_147_483_646; // intの最大値
    static final int INF = 1_000_000_000; // 10^9
    static final int MAX = 10_000_000;
    static long[] fact = new long[100];

    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();
        h *= 30;
        m*=6;
        //System.out.println(h+" "+m);
        //何度
        double rad = h-m;
        rad+=(double)m/12;
        if(rad>180)rad -=360;
        if(rad<0)rad*=-1;
        //System.out.println(rad);
        //System.out.println(Math.acos(rad));
        rad = rad*Math.PI/180;
        
        //rad =Math.PI*80/180;
        //System.out.println(rad);
        //System.out.println(Math.cos(rad));
        double ans = a*a +b*b - 2*a*b*Math.cos(rad);
        //System.out.println(ans);
        System.out.println(Math.sqrt(ans));
    }
} Main
import java.util.*;
import java.math.*;

public class Main {
    static final int MOD = 1_000_000_007; // 10^9+7
    // static final int MAX = 2_147_483_646; // intの最大値
    static final int INF = 1_000_000_000; // 10^9
    static final int MAX = 10_000_000;
    static long[] fact = new long[100];

    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();
        h *= 30;
        m*=6;
        //System.out.println(h+" "+m);
        //何度
        double rad = h-m;
        rad+=(double)m/12;
        if(rad>180)rad -=360;
        if(rad<0)rad*=-1;
        //System.out.println(rad);
        //System.out.println(Math.acos(rad));
        rad = rad*Math.PI/180;
        
        //rad =Math.PI*80/180;
        //System.out.println(rad);
        //System.out.println(Math.cos(rad));
        double ans = a*a +b*b - 2*a*b*Math.cos(rad);
        //System.out.println(ans);
        System.out.println(Math.sqrt(ans));
    }
}
