import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    long a = scan.nextLong();
    long b = scan.nextLong();
    int c = scan.nextInt();
    int d = scan.nextInt();
    double e = 0;
    long f = 0;
    for (int i=0;i<d;i++){
      f += 6;
      e += 0.5;
    }
    for (int j=0;j<c;j++){
      e += 30;
    }

    double t = e-f;
    while ((t>180)||(t<0)){
      if (t<0){
        t+=360;
        continue;
      }
      if (t>180){
        t = 360 - t;
      }
    }

    double radian = Math.toRadians(t);
    double gg = a*a+b*b-2*a*b*(Math.cos(radian));
    gg = Math.sqrt(gg);
    System.out.println(gg);
  }
} import java.util.*; util.* java public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    long a = scan.nextLong();
    long b = scan.nextLong();
    int c = scan.nextInt();
    int d = scan.nextInt();
    double e = 0;
    long f = 0;
    for (int i=0;i<d;i++){
      f += 6;
      e += 0.5;
    }
    for (int j=0;j<c;j++){
      e += 30;
    }

    double t = e-f;
    while ((t>180)||(t<0)){
      if (t<0){
        t+=360;
        continue;
      }
      if (t>180){
        t = 360 - t;
      }
    }

    double radian = Math.toRadians(t);
    double gg = a*a+b*b-2*a*b*(Math.cos(radian));
    gg = Math.sqrt(gg);
    System.out.println(gg);
  }
} Main public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    long a = scan.nextLong();
    long b = scan.nextLong();
    int c = scan.nextInt();
    int d = scan.nextInt();
    double e = 0;
    long f = 0;
    for (int i=0;i<d;i++){
      f += 6;
      e += 0.5;
    }
    for (int j=0;j<c;j++){
      e += 30;
    }

    double t = e-f;
    while ((t>180)||(t<0)){
      if (t<0){
        t+=360;
        continue;
      }
      if (t>180){
        t = 360 - t;
      }
    }

    double radian = Math.toRadians(t);
    double gg = a*a+b*b-2*a*b*(Math.cos(radian));
    gg = Math.sqrt(gg);
    System.out.println(gg);
  } main {
    Scanner scan = new Scanner(System.in);
    long a = scan.nextLong();
    long b = scan.nextLong();
    int c = scan.nextInt();
    int d = scan.nextInt();
    double e = 0;
    long f = 0;
    for (int i=0;i<d;i++){
      f += 6;
      e += 0.5;
    }
    for (int j=0;j<c;j++){
      e += 30;
    }

    double t = e-f;
    while ((t>180)||(t<0)){
      if (t<0){
        t+=360;
        continue;
      }
      if (t>180){
        t = 360 - t;
      }
    }

    double radian = Math.toRadians(t);
    double gg = a*a+b*b-2*a*b*(Math.cos(radian));
    gg = Math.sqrt(gg);
    System.out.println(gg);
  } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) long a = scan.nextLong(); a scan.nextLong() scan.nextLong scan long b = scan.nextLong(); b scan.nextLong() scan.nextLong scan int c = scan.nextInt(); c scan.nextInt() scan.nextInt scan int d = scan.nextInt(); d scan.nextInt() scan.nextInt scan double e = 0; e 0 long f = 0; f 0 for (int i=0;i<d;i++){
      f += 6;
      e += 0.5;
    } int i=0; int i=0; i 0 i<d i d i++ i++ i {
      f += 6;
      e += 0.5;
    } {
      f += 6;
      e += 0.5;
    } f += 6 f 6 e += 0.5 e 0.5 for (int j=0;j<c;j++){
      e += 30;
    } int j=0; int j=0; j 0 j<c j c j++ j++ j {
      e += 30;
    } {
      e += 30;
    } e += 30 e 30 double t = e-f; t e-f e f while ((t>180)||(t<0)){
      if (t<0){
        t+=360;
        continue;
      }
      if (t>180){
        t = 360 - t;
      }
    } (t>180)||(t<0) (t>180) t 180 (t<0) t 0 {
      if (t<0){
        t+=360;
        continue;
      }
      if (t>180){
        t = 360 - t;
      }
    } if (t<0){
        t+=360;
        continue;
      } t<0 t 0 {
        t+=360;
        continue;
      } t+=360 t 360 continue; if (t>180){
        t = 360 - t;
      } t>180 t 180 {
        t = 360 - t;
      } t = 360 - t t 360 - t 360 t double radian = Math.toRadians(t); radian Math.toRadians(t) Math.toRadians Math t double gg = a*a+b*b-2*a*b*(Math.cos(radian)); gg a*a+b*b-2*a*b*(Math.cos(radian)) a*a+b*b a*a a a b*b b b 2*a*b*(Math.cos(radian)) b 2*a*b*(Math.cos(radian)) 2 a b (Math.cos(radian)) Math.cos Math radian gg = Math.sqrt(gg) gg Math.sqrt(gg) Math.sqrt Math gg System.out.println(gg) System.out.println System.out System System.out gg String[] args args public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    long a = scan.nextLong();
    long b = scan.nextLong();
    int c = scan.nextInt();
    int d = scan.nextInt();
    double e = 0;
    long f = 0;
    for (int i=0;i<d;i++){
      f += 6;
      e += 0.5;
    }
    for (int j=0;j<c;j++){
      e += 30;
    }

    double t = e-f;
    while ((t>180)||(t<0)){
      if (t<0){
        t+=360;
        continue;
      }
      if (t>180){
        t = 360 - t;
      }
    }

    double radian = Math.toRadians(t);
    double gg = a*a+b*b-2*a*b*(Math.cos(radian));
    gg = Math.sqrt(gg);
    System.out.println(gg);
  }
} public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    long a = scan.nextLong();
    long b = scan.nextLong();
    int c = scan.nextInt();
    int d = scan.nextInt();
    double e = 0;
    long f = 0;
    for (int i=0;i<d;i++){
      f += 6;
      e += 0.5;
    }
    for (int j=0;j<c;j++){
      e += 30;
    }

    double t = e-f;
    while ((t>180)||(t<0)){
      if (t<0){
        t+=360;
        continue;
      }
      if (t>180){
        t = 360 - t;
      }
    }

    double radian = Math.toRadians(t);
    double gg = a*a+b*b-2*a*b*(Math.cos(radian));
    gg = Math.sqrt(gg);
    System.out.println(gg);
  }
} Main
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    long a = scan.nextLong();
    long b = scan.nextLong();
    int c = scan.nextInt();
    int d = scan.nextInt();
    double e = 0;
    long f = 0;
    for (int i=0;i<d;i++){
      f += 6;
      e += 0.5;
    }
    for (int j=0;j<c;j++){
      e += 30;
    }

    double t = e-f;
    while ((t>180)||(t<0)){
      if (t<0){
        t+=360;
        continue;
      }
      if (t>180){
        t = 360 - t;
      }
    }

    double radian = Math.toRadians(t);
    double gg = a*a+b*b-2*a*b*(Math.cos(radian));
    gg = Math.sqrt(gg);
    System.out.println(gg);
  }
}
