Problem: Two neighbours, Alan and Bob, live in the city, where there are three buildings only: a cinema, a shop and the house, where they live. The rest is a big asphalt square. 

Once they went to the cinema, and the film impressed them so deeply, that when they left the cinema, they did not want to stop discussing it.

Bob wants to get home, but Alan has to go to the shop first, and only then go home. So, they agreed to cover some distance together discussing the film (their common path might pass through the shop, or they might walk circles around the cinema together), and then to part each other's company and go each his own way. After they part, they will start thinking about their daily pursuits; and even if they meet again, they won't be able to go on with the discussion. Thus, Bob's path will be a continuous curve, having the cinema and the house as its ends. Alan's path — a continuous curve, going through the shop, and having the cinema and the house as its ends.

The film ended late, that's why the whole distance covered by Alan should not differ from the shortest one by more than t1, and the distance covered by Bob should not differ from the shortest one by more than t2.

Find the maximum distance that Alan and Bob will cover together, discussing the film.

Input

The first line contains two integers: t1, t2 (0 ≤ t1, t2 ≤ 100). The second line contains the cinema's coordinates, the third one — the house's, and the last line — the shop's. 

All the coordinates are given in meters, are integer, and do not exceed 100 in absolute magnitude. No two given places are in the same building.

Output

In the only line output one number — the maximum distance that Alan and Bob will cover together, discussing the film. Output the answer accurate to not less than 4 decimal places.

Examples

Input

0 2
0 0
4 0
-3 0


Output

1.0000000000


Input

0 0
0 0
2 0
1 0


Output

2.0000000000

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
struct point {
  double x, y;
  point(double a = 0, double b = 0) {
    x = a;
    y = b;
  }
  point operator+(const point &b) const { return point(x + b.x, y + b.y); }
  point operator-(const point &b) const { return point(x - b.x, y - b.y); }
  double operator*(const point &b) const { return x * b.x + y * b.y; }
  double operator^(const point &b) const { return x * b.y - y * b.x; }
  void transxy(double sinb, double cosb) {
    double tx = x, ty = y;
    x = tx * cosb - ty * sinb;
    y = tx * sinb + ty * cosb;
  }
  void transxy(double b) {
    double tx = x, ty = y;
    x = tx * cos(b) - ty * sin(b);
    y = tx * sin(b) + ty * cos(b);
  }
  double get_len() { return sqrt(x * x + y * y); }
} cinema, shop, house, intersec1, intersec2;
struct circle {
  point ctr;
  double r;
  circle(point a = point(), double radius = 0) {
    ctr = a;
    r = radius;
  }
};
double t1, t2, l1, l2, ans;
double get_dist(point &a, point &b) {
  return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}
inline void prework() {
  scanf("%lf%lf", &t1, &t2);
  scanf("%lf%lf", &cinema.x, &cinema.y);
  scanf("%lf%lf", &house.x, &house.y);
  scanf("%lf%lf", &shop.x, &shop.y);
  l1 = get_dist(cinema, shop) + get_dist(shop, house) + t1;
  l2 = get_dist(cinema, house) + t2;
}
inline bool get_circle_intersec(point a, double ra, point b, double rb) {
  double len = get_dist(a, b);
  if (len > ra + rb + 1e-10) return false;
  double cosb = (ra * ra + len * len - rb * rb) / (2 * ra * len);
  if (cosb < -1.0) cosb += 1e-10;
  if (cosb > 1.0) cosb -= 1e-10;
  double sinb = sqrt(1.0 - cosb * cosb);
  point vec = b - a;
  vec.transxy(sinb, cosb);
  double t = (ra / sqrt(vec * vec));
  intersec1 = a + point(vec.x * t, vec.y * t);
  vec = b - a;
  vec.transxy(-sinb, cosb);
  intersec2 = a + point(vec.x * t, vec.y * t);
  return true;
}
inline bool cmp(const circle &x, const circle &y) { return x.r < y.r; }
inline bool jug(double x) {
  double r[3];
  r[0] = x, r[1] = l1 - get_dist(shop, house) - x, r[2] = l2 - x;
  if (r[0] <= 1e-10 || r[1] <= 1e-10 || r[2] <= 1e-10) return false;
  circle cir[3];
  cir[0] = circle(cinema, r[0]);
  cir[1] = circle(shop, r[1]);
  cir[2] = circle(house, r[2]);
  if (get_circle_intersec(cinema, r[0], shop, r[1])) {
    if (get_dist(intersec1, house) < r[2] + 1e-10) return true;
    if (get_dist(intersec2, house) < r[2] + 1e-10) return true;
  }
  if (get_circle_intersec(cinema, r[0], house, r[2])) {
    if (get_dist(intersec1, shop) < r[1] + 1e-10) return true;
    if (get_dist(intersec2, shop) < r[1] + 1e-10) return true;
  }
  if (get_circle_intersec(shop, r[1], house, r[2])) {
    if (get_dist(intersec1, cinema) < r[0] + 1e-10) return true;
    if (get_dist(intersec2, cinema) < r[0] + 1e-10) return true;
  }
  sort(cir, cir + 3, cmp);
  if ((cir[0].ctr - cir[1].ctr).get_len() + cir[0].r < cir[1].r + 1e-10 &&
      (cir[0].ctr - cir[2].ctr).get_len() + cir[0].r < cir[2].r + 1e-10)
    return true;
  if ((cir[0].ctr - cir[1].ctr).get_len() + cir[0].r < cir[1].r + 1e-10 &&
      (cir[1].ctr - cir[2].ctr).get_len() + cir[1].r < cir[2].r + 1e-10)
    return true;
  return false;
}
inline void mainwork() {
  if (get_dist(cinema, shop) + get_dist(shop, house) < l2 + 1e-10)
    ans = min(l1, l2);
  else {
    double l = 0, r = min(l1, l2), mid;
    while (l + 1e-10 < r) {
      mid = (l + r) / 2.0;
      if (jug(mid))
        l = mid;
      else
        r = mid;
    }
    ans = r;
  }
}
inline void print() { printf("%.10f", ans); }
int main() {
  prework();
  mainwork();
  print();
  return 0;
}