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>
double dt1, dt2, delt, t1, t2;
std::pair<double, double> c, h, s, p;
double d1[2 * 60], d2[2 * 60];
inline double dist(std::pair<double, double> a, std::pair<double, double> b) {
  return sqrt((a.first - b.first) * (a.first - b.first) +
              (a.second - b.second) * (a.second - b.second));
}
inline double min2(double a, double b) { return a < b ? a : b; }
double score(std::pair<double, double> p) {
  double a, b;
  a = t1 + dt1 - dist(p, h);
  if (a < dist(c, p) - 1E-5) return -1;
  b = t2 + dt2 - dist(p, s) - dist(s, h);
  if (b < dist(c, p) - 1E-5) return -1;
  return min2(a, b);
}
double score2(std::pair<double, double> p) {
  double a, b;
  a = t1 + dt1 - dist(p, h);
  if (a < dist(c, p) - 1E-5) return -1;
  b = t2 + dt2 - dist(p, h);
  if (b < dist(c, p) - 1E-5) return -1;
  return min2(a, b);
}
double solve(double *d1, double *d2) {
  delt = 1;
  p = c;
  char g;
  int i;
  std::pair<double, double> np;
  while (delt > 1E-5) {
    g = 0;
    for (i = 0; i < 60 && g == 0; i++) {
      np = std::make_pair(p.first + delt * d1[i], p.second + delt * d2[i]);
      if (score(np) > score(p) + 1E-5) p = np, g = 1;
    }
    if (!g) delt *= 0.7;
  }
  return score(p);
}
double solve2(double *d1, double *d2) {
  delt = 1;
  p = c;
  char g;
  int i;
  std::pair<double, double> np;
  while (delt > 1E-5) {
    g = 0;
    for (i = 0; i < 60 && g == 0; i++) {
      np = std::make_pair(p.first + delt * d1[i], p.second + delt * d2[i]);
      if (score2(np) > score2(p) + 1E-5) p = np, g = 1;
    }
    if (!g) delt *= 0.7;
  }
  return score2(p);
}
int main() {
  double rez;
  scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &dt2, &dt1, &c.first, &c.second, &h.first,
        &h.second, &s.first, &s.second);
  t1 = dist(c, h);
  t2 = dist(c, s) + dist(s, h);
  for (int i = 0; i < 60; i++) {
    d1[i] = cos(2 * i * 3.141592653589793 / 60);
    d2[i] = sin(2 * i * 3.141592653589793 / 60);
  }
  for (int i = 60; i < 2 * 60; i++) {
    d1[i] = d1[i - 60];
    d2[i] = d2[i - 60];
  }
  if (dt1 != 0 && dt2 != 0) {
    double aux, ca;
    rez = 0;
    for (int i = 0; i < 60; i++) {
      aux = solve(d1 + i, d2 + i);
      if (rez < aux) rez = aux;
    }
    if (dist(c, s) + dist(s, h) <= t1 + dt1) {
      double cr = dist(c, s);
      t1 -= dist(c, s);
      t2 -= dist(c, s);
      c = s;
      ca = 0;
      for (int i = 0; i < 60; i++) {
        aux = solve2(d1 + i, d2 + i);
        if (ca < aux) ca = aux;
      }
      cr += ca;
      if (cr > rez) rez = cr;
    }
    printf("%.12lf", rez);
  } else {
    double ang;
    std::pair<double, double> np;
    if (dt1 == 0) {
      if (dist(c, s) + dist(s, h) < t1 + dt1 + 1E-5)
        rez = t2;
      else {
        ang = atan2(h.second - c.second, h.first - c.first);
        delt = 1;
        p = c;
        rez = 0;
        while (delt > 1E-5) {
          np = std::make_pair(p.first + delt * cos(ang),
                              p.second + delt * sin(ang));
          if (rez + delt < t1 + 1E-5 &&
              dist(c, np) + dist(np, s) + dist(s, h) < t2 + dt2 + 1E-5)
            p = np, rez += delt;
          else
            delt *= 0.7;
        }
      }
    } else {
      if (dist(c, s) + dist(s, h) < t1 + dt1 + 1E-5)
        rez = t2;
      else {
        ang = atan2(s.second - c.second, s.first - c.first);
        delt = 1;
        p = c;
        rez = 0;
        while (delt > 1E-5) {
          np = std::make_pair(p.first + delt * cos(ang),
                              p.second + delt * sin(ang));
          if (rez + delt < dist(c, s) + 1E-5 &&
              dist(c, np) + dist(np, h) < t1 + dt1 + 1E-5)
            p = np, rez += delt;
          else
            delt *= 0.7;
        }
      }
    }
    printf("%.12lf", rez);
  }
  return 0;
}