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;
using lint = long long;
struct point {
  double x, y;
  point operator-(const point& r) const { return point{x - r.x, y - r.y}; }
  point operator+(const point& r) const { return point{x + r.x, y + r.y}; }
  point operator*(double k) const { return point{x * k, y * k}; }
  double operator*(const point& r) const { return x * r.y - y * r.x; }
};
point norm(const point& r) {
  double t = sqrt(r.x * r.x + r.y * r.y);
  return point{r.x / t, r.y / t};
}
point rot(const point& r, double ang) {
  point res;
  res.x = r.x * cos(ang) - r.y * sin(ang);
  res.y = r.x * sin(ang) + r.y * cos(ang);
  return res;
}
double dist(point a, point b) {
  return sqrt(pow(a.x - b.x, 2) + pow(a.y - b.y, 2));
}
bool is_inter(point a, double ra, point b, double rb) {
  double d = dist(a, b);
  double r1 = max(ra, rb);
  double r2 = min(ra, rb);
  if (d >= r1 && r1 + r2 >= d) {
    return true;
  }
  if (d < r1 && d + r2 >= r1) {
    return true;
  }
  return false;
}
bool p_ins(point a, double ra, point p) { return dist(a, p) <= ra; }
bool inter3(point a, double ra, point b, double rb, point c, double rc) {
  if (p_ins(a, ra, c) && p_ins(b, rb, c)) {
    return true;
  }
  if (!is_inter(a, ra, b, rb)) {
    return false;
  }
  double d = dist(a, b);
  double ang = acos((ra * ra + d * d - rb * rb) / (2 * ra * d));
  point z1 = rot(norm(b - a), ang) * ra + a;
  point z2 = rot(norm(b - a), -ang) * ra + a;
  if (p_ins(c, rc, z1) || p_ins(c, rc, z2)) {
    return true;
  }
  return false;
}
bool check(point a, double ra, point b, double rb, point c, double rc) {
  if (ra < 0 || rb < 0 || rc < 0) {
    return false;
  }
  bool f = inter3(a, ra, b, rb, c, rc) || inter3(a, ra, c, rc, b, rb) ||
           inter3(b, rb, c, rc, a, ra);
  return f;
}
void solve(istream& cin, ostream& cout) {
  cout << setprecision(11) << fixed;
  int t1, t2;
  cin >> t1 >> t2;
  point a, b, c;
  cin >> a.x >> a.y >> b.x >> b.y >> c.x >> c.y;
  double o1 = dist(a, c) + dist(c, b);
  double o2 = dist(a, b);
  double a1 = 0;
  double a2 = 0;
  if (dist(a, b) + dist(b, c) * 2 - o1 <= t1) {
    a1 = dist(a, b) + min<double>(t2, t1 + o1 - dist(a, b) - dist(b, c) * 2);
  } else {
    double l = 0;
    double r = 1;
    point t;
    for (int i = 0; i < 1000; i++) {
      double m = (l + r) / 2;
      t.x = a.x + (b.x - a.x) * m;
      t.y = a.y + (b.y - a.y) * m;
      if (dist(a, t) + dist(t, c) + dist(c, b) - o1 <= t1) {
        l = m;
      } else {
        r = m;
      }
    }
    a1 = dist(a, t);
  }
  if (dist(a, c) + dist(b, c) - o2 <= t2) {
    a2 = dist(a, c) + dist(b, c) +
         min<double>(t1, t2 + o2 - dist(a, c) - dist(b, c));
  } else {
    double l = 0;
    double r = 1;
    point t;
    for (int i = 0; i < 1000; i++) {
      double m = (l + r) / 2;
      t.x = a.x + (c.x - a.x) * m;
      t.y = a.y + (c.y - a.y) * m;
      if (dist(a, t) + dist(t, b) - o2 <= t2) {
        l = m;
      } else {
        r = m;
      }
    }
    a2 = dist(a, t);
  }
  double ac = dist(a, c);
  double ab = dist(a, b);
  double bc = dist(b, c);
  double ang = acos((ac * ac + ab * ab - bc * bc) / (2 * ab * ac));
  if ((b - a) * (c - a) < 0) {
    ang = -ang;
  }
  double l = 0;
  double r = 1e5;
  for (int i = 0; i < 2000; i++) {
    double m = (l + r) / 2;
    if (check(a, m, c, o1 + t1 - m - dist(b, c), b, o2 + t2 - m)) {
      l = m;
    } else {
      r = m;
    }
  }
  double a3 = l;
  cout << max(a1, max(a2, a3));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve(cin, cout);
  return 0;
}