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 long double eps = 1e-14;
inline long double sqr(long double x) { return x * x; }
inline int sgn(long double x) { return fabs(x) < eps ? 0 : x > 0 ? 1 : -1; }
struct point {
  long double x, y;
};
inline point operator-(point a, point b) {
  return (point){a.x - b.x, a.y - b.y};
}
inline point operator+(point a, point b) {
  return (point){a.x + b.x, a.y + b.y};
}
inline point operator*(point a, long double l) {
  return (point){a.x * l, a.y * l};
}
inline long double sModular(point a) { return sqr(a.x) + sqr(a.y); }
inline point identity(point a) {
  long double m = sqrt(sModular(a));
  return a * (1.0 / m);
}
struct circle {
  point p;
  long double r;
};
inline bool inside(circle a, point p) {
  return sgn(sModular(a.p - p) - sqr(a.r)) <= 0;
}
inline bool inside(circle a, circle b) {
  long double sqDis = sModular(a.p - b.p);
  return sgn(b.r - a.r) < 0 && sgn(sqDis - sqr(a.r - b.r)) < 0;
}
inline bool intersect(circle &a, circle &b, point &x, point &y) {
  long double sqDis = sModular(a.p - b.p);
  if (sgn(sqDis - sqr(a.r + b.r)) > 0) return false;
  long double dPar = (sqr(a.r) - sqr(b.r) + sqDis) / (2.0 * sqrt(sqDis)),
              dHor = sqrt(max((long double)0, sqr(a.r) - sqr(dPar)));
  point i = identity(b.p - a.p), j = (point){i.y, -i.x};
  x = a.p + i * dPar + j * dHor;
  y = a.p + i * dPar - j * dHor;
  return true;
}
inline bool _intersect(circle &a, circle &b, circle &c) {
  point x, y;
  if (inside(a, b)) return intersect(b, c, x, y);
  if (inside(b, a)) return intersect(a, c, x, y);
  if (!intersect(a, b, x, y)) return false;
  return inside(c, x) || inside(c, y);
}
inline bool intersect(circle a, circle b, circle c) {
  return _intersect(a, b, c) || _intersect(a, c, b) || _intersect(b, c, a);
}
point C, S, H;
long double T1, T2, dHS;
inline bool check(long double x) {
  circle CC = (circle){C, x},
         CS = (circle){S, max((long double)0, T1 - x - dHS)},
         CH = (circle){H, max((long double)0, T2 - x)};
  return intersect(CC, CS, CH);
}
int main() {
  long double t1, t2;
  cin >> t1 >> t2 >> C.x >> C.y >> H.x >> H.y >> S.x >> S.y;
  T1 = sqrt(sModular(S - C)) + sqrt(sModular(H - S)) + t1;
  T2 = sqrt(sModular(C - H)) + t2;
  dHS = sqrt(sModular(H - S));
  if (sgn(T2 - (T1 - t1)) >= 0) {
    cout.setf(ios::fixed);
    cout << setprecision(18) << min(T1, T2) << endl;
    return 0;
  }
  long double l = 0, r = min(T1 - dHS, T2), m;
  for (int _ = 0; _ <= 300; ++_) {
    m = (l + r) / 2.0;
    if (check(m))
      l = m;
    else
      r = m;
  }
  cout.setf(ios::fixed);
  cout << setprecision(18) << l << endl;
}