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;
struct Point {
  double x, y;
  Point() {}
  Point(double _x, double _y) : x(_x), y(_y) {}
  Point operator+(const Point& p) const { return Point(x + p.x, y + p.y); }
  Point operator-(const Point& p) const { return Point(x - p.x, y - p.y); }
  Point operator*(double d) const { return Point(x * d, y * d); }
  Point operator/(double d) const { return Point(x / d, y / d); }
  double det(const Point& p) const { return x * p.y - y * p.x; }
  double dot(const Point& p) const { return x * p.x + y * p.y; }
  double alpha() const { return atan2(y, x); }
  Point rot90() const { return Point(-y, x); }
  void read() { scanf("%lf%lf", &x, &y); }
  void write() const { printf("(%lf,%lf)", x, y); }
  double abs() { return hypot(x, y); }
  double abs2() { return x * x + y * y; }
  Point unit() { return *this / abs(); }
  double distTo(const Point& p) const { return hypot(x - p.x, y - p.y); }
};
const double EPS = 1e-10;
inline int sign(double a) { return a < -EPS ? -1 : a > EPS; }
Point isSS(Point p1, Point p2, Point q1, Point q2) {
  double a1 = ((q2.x - q1.x) * (p1.y - q1.y) - (p1.x - q1.x) * (q2.y - q1.y)),
         a2 = -((q2.x - q1.x) * (p2.y - q1.y) - (p2.x - q1.x) * (q2.y - q1.y));
  return (p1 * a2 + p2 * a1) / (a1 + a2);
}
vector<Point> make(Point a, Point b) {
  vector<Point> ret;
  ret.push_back(a);
  ret.push_back(b);
  return ret;
}
vector<Point> tanCP(Point c, double r, Point p) {
  double x2 = (p - c).abs2();
  double d2 = x2 - r * r;
  vector<Point> ret;
  if (d2 < -EPS) return ret;
  if (r <= EPS) {
    ret.push_back(c);
    ret.push_back(c);
    return ret;
  }
  d2 = max(d2, 0.);
  Point q1 = c + (p - c) * (r * r / x2);
  Point q2 = (p - c).rot90() * (-r * sqrt(d2) / x2);
  ret.push_back(q1 - q2);
  ret.push_back(q1 + q2);
  return ret;
}
vector<vector<Point> > tanCC(Point c1, double r1, Point c2, double r2) {
  vector<vector<Point> > ret;
  if (fabs(r1 - r2) <= EPS) {
    Point dir = (c2 - c1).unit().rot90() * r1;
    ret.push_back(make(c1 + dir, c2 + dir));
    ret.push_back(make(c1 - dir, c2 - dir));
  } else {
    Point p = (c2 * r1 - c1 * r2) / (r1 - r2);
    vector<Point> ps = tanCP(c1, r1, p);
    vector<Point> qs = tanCP(c2, r2, p);
    for (int i = 0; i < ps.size() && i < qs.size(); ++i) {
      ret.push_back(make(ps[i], qs[i]));
    }
  }
  return ret;
}
vector<Point> isCC(Point c1, double r1, Point c2, double r2) {
  double d = c1.distTo(c2);
  if (d > r1 + r2 + EPS || d <= fabs(r1 - r2) - EPS) return vector<Point>();
  double w = (r1 * r1 + d * d - r2 * r2) / (2 * d);
  double h = sqrt(max(r1 * r1 - w * w, 0.0));
  Point at = c1 + (c2 - c1) * (w / d);
  Point dir = (c2 - c1).rot90() * (h / d);
  vector<Point> ps;
  ps.push_back(at - dir);
  ps.push_back(at + dir);
  return ps;
}
bool inCP(Point p, double r, Point q) { return p.distTo(q) <= r + EPS; }
bool checkCommon(vector<Point> ps, vector<double> rs) {
  vector<Point> chk = ps;
  for (int i = 0; i < ps.size(); ++i) {
    for (int j = 0; j < i; ++j) {
      vector<Point> is = isCC(ps[i], rs[i], ps[j], rs[j]);
      chk.insert(chk.end(), is.begin(), is.end());
    }
  }
  for (int i = 0; i < chk.size(); ++i) {
    bool ok = true;
    for (int j = 0; j < ps.size(); ++j) {
      if (!inCP(ps[j], rs[j], chk[i])) ok = false;
    }
    if (ok) return true;
  }
  return false;
}
int main() {
  double a, b;
  cin >> a >> b;
  Point cinema, house, shop;
  cinema.read(), house.read(), shop.read();
  double maxA = cinema.distTo(shop) + shop.distTo(house) + a;
  double maxB = cinema.distTo(house) + b;
  if (maxB > cinema.distTo(shop) + shop.distTo(house) - EPS) {
    printf("%0.10lf\n", min(maxA, maxB));
    return 0;
  }
  double l = 0, r = min(maxA, maxB) + 0.1;
  while (l + 1e-10 < r) {
    double m = (l + r) / 2;
    double remA = maxA - shop.distTo(house) - m;
    double remB = maxB - m;
    vector<Point> ps;
    ps.push_back(cinema), ps.push_back(shop), ps.push_back(house);
    vector<double> rs;
    rs.push_back(m), rs.push_back(remA), rs.push_back(remB);
    if (checkCommon(ps, rs))
      l = m;
    else
      r = m;
  }
  printf("%0.10lf\n", l);
  return 0;
}