
import java.util.Scanner;

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();
    sc.close();

    double hd = (60 * h + m) * 0.5;
    double md = m * 6;

    double r = 0.000000000;
    if(hd < md) {
      r = md - hd;
      if(r > 180) {
        r = 360 - r;
      }
      double ans = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(r * Math.PI/180));
      System.out.println(ans);
    }else if(hd > md) {
      r = hd - md;
      if(r > 180) {
        r = 360 - r;
      }
      double ans = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(r * Math.PI/180));
      System.out.println(ans);
    }else {
      System.out.println(Math.abs(a-b));
    }
  }

} import java.util.Scanner; Scanner java.util 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();
    sc.close();

    double hd = (60 * h + m) * 0.5;
    double md = m * 6;

    double r = 0.000000000;
    if(hd < md) {
      r = md - hd;
      if(r > 180) {
        r = 360 - r;
      }
      double ans = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(r * Math.PI/180));
      System.out.println(ans);
    }else if(hd > md) {
      r = hd - md;
      if(r > 180) {
        r = 360 - r;
      }
      double ans = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(r * Math.PI/180));
      System.out.println(ans);
    }else {
      System.out.println(Math.abs(a-b));
    }
  }

} 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();
    sc.close();

    double hd = (60 * h + m) * 0.5;
    double md = m * 6;

    double r = 0.000000000;
    if(hd < md) {
      r = md - hd;
      if(r > 180) {
        r = 360 - r;
      }
      double ans = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(r * Math.PI/180));
      System.out.println(ans);
    }else if(hd > md) {
      r = hd - md;
      if(r > 180) {
        r = 360 - r;
      }
      double ans = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(r * Math.PI/180));
      System.out.println(ans);
    }else {
      System.out.println(Math.abs(a-b));
    }
  } main {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int h = sc.nextInt();
    int m = sc.nextInt();
    sc.close();

    double hd = (60 * h + m) * 0.5;
    double md = m * 6;

    double r = 0.000000000;
    if(hd < md) {
      r = md - hd;
      if(r > 180) {
        r = 360 - r;
      }
      double ans = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(r * Math.PI/180));
      System.out.println(ans);
    }else if(hd > md) {
      r = hd - md;
      if(r > 180) {
        r = 360 - r;
      }
      double ans = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(r * Math.PI/180));
      System.out.println(ans);
    }else {
      System.out.println(Math.abs(a-b));
    }
  } 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 sc.close() sc.close sc double hd = (60 * h + m) * 0.5; hd (60 * h + m) * 0.5 (60 * h + m) 60 * h 60 h m 0.5 double md = m * 6; md m * 6 m 6 double r = 0.000000000; r 0.000000000 if(hd < md) {
      r = md - hd;
      if(r > 180) {
        r = 360 - r;
      }
      double ans = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(r * Math.PI/180));
      System.out.println(ans);
    }else if(hd > md) {
      r = hd - md;
      if(r > 180) {
        r = 360 - r;
      }
      double ans = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(r * Math.PI/180));
      System.out.println(ans);
    }else {
      System.out.println(Math.abs(a-b));
    } hd < md hd md {
      r = md - hd;
      if(r > 180) {
        r = 360 - r;
      }
      double ans = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(r * Math.PI/180));
      System.out.println(ans);
    } r = md - hd r md - hd md hd if(r > 180) {
        r = 360 - r;
      } r > 180 r 180 {
        r = 360 - r;
      } r = 360 - r r 360 - r 360 r double ans = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(r * Math.PI/180)); ans Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(r * Math.PI/180)) Math.sqrt Math a * a + b * b - 2 * a * b * Math.cos(r * Math.PI/180) a * a + b * b a * a a a b * b b b 2 * a * b * Math.cos(r * Math.PI/180) b 2 * a * b * Math.cos(r * Math.PI/180) 2 a b Math.cos(r * Math.PI/180) Math.cos Math r * Math.PI/180 r * Math.PI r Math.PI Math Math.PI 180 System.out.println(ans) System.out.println System.out System System.out ans if(hd > md) {
      r = hd - md;
      if(r > 180) {
        r = 360 - r;
      }
      double ans = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(r * Math.PI/180));
      System.out.println(ans);
    }else {
      System.out.println(Math.abs(a-b));
    } hd > md hd md {
      r = hd - md;
      if(r > 180) {
        r = 360 - r;
      }
      double ans = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(r * Math.PI/180));
      System.out.println(ans);
    } r = hd - md r hd - md hd md if(r > 180) {
        r = 360 - r;
      } r > 180 r 180 {
        r = 360 - r;
      } r = 360 - r r 360 - r 360 r double ans = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(r * Math.PI/180)); ans Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(r * Math.PI/180)) Math.sqrt Math a * a + b * b - 2 * a * b * Math.cos(r * Math.PI/180) a * a + b * b a * a a a b * b b b 2 * a * b * Math.cos(r * Math.PI/180) b 2 * a * b * Math.cos(r * Math.PI/180) 2 a b Math.cos(r * Math.PI/180) Math.cos Math r * Math.PI/180 r * Math.PI r Math.PI Math Math.PI 180 System.out.println(ans) System.out.println System.out System System.out ans {
      System.out.println(Math.abs(a-b));
    } System.out.println(Math.abs(a-b)) System.out.println System.out System System.out Math.abs(a-b) Math.abs Math a-b a b 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();
    sc.close();

    double hd = (60 * h + m) * 0.5;
    double md = m * 6;

    double r = 0.000000000;
    if(hd < md) {
      r = md - hd;
      if(r > 180) {
        r = 360 - r;
      }
      double ans = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(r * Math.PI/180));
      System.out.println(ans);
    }else if(hd > md) {
      r = hd - md;
      if(r > 180) {
        r = 360 - r;
      }
      double ans = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(r * Math.PI/180));
      System.out.println(ans);
    }else {
      System.out.println(Math.abs(a-b));
    }
  }

} 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();
    sc.close();

    double hd = (60 * h + m) * 0.5;
    double md = m * 6;

    double r = 0.000000000;
    if(hd < md) {
      r = md - hd;
      if(r > 180) {
        r = 360 - r;
      }
      double ans = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(r * Math.PI/180));
      System.out.println(ans);
    }else if(hd > md) {
      r = hd - md;
      if(r > 180) {
        r = 360 - r;
      }
      double ans = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(r * Math.PI/180));
      System.out.println(ans);
    }else {
      System.out.println(Math.abs(a-b));
    }
  }

} Main

import java.util.Scanner;

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();
    sc.close();

    double hd = (60 * h + m) * 0.5;
    double md = m * 6;

    double r = 0.000000000;
    if(hd < md) {
      r = md - hd;
      if(r > 180) {
        r = 360 - r;
      }
      double ans = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(r * Math.PI/180));
      System.out.println(ans);
    }else if(hd > md) {
      r = hd - md;
      if(r > 180) {
        r = 360 - r;
      }
      double ans = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(r * Math.PI/180));
      System.out.println(ans);
    }else {
      System.out.println(Math.abs(a-b));
    }
  }

}
