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;
template <class _T>
inline _T sqr(const _T& x) {
  return x * x;
}
template <class _T>
inline string tostr(const _T& a) {
  ostringstream os("");
  os << a;
  return os.str();
}
const long double PI = 3.1415926535897932384626433832795;
const long double EPS = 1e-14;
const long double EPS2 = 1e-14;
struct tp {
  long double x, y;
};
long double t1, t2;
tp p0, p1, p2;
long double d01, d02, d12;
long double dist(tp p1, tp p2) {
  return sqrtl(sqr(p1.x - p2.x) + sqr(p1.y - p2.y));
}
long double dist2(tp p1, tp p2) {
  return (sqr(p1.x - p2.x) + sqr(p1.y - p2.y));
}
void rot(tp& p, long double aa) {
  long double sn = sinl(aa);
  long double cs = cosl(aa);
  tp pn;
  pn.x = p.x * cs - p.y * sn;
  pn.y = p.y * cs + p.x * sn;
  p = pn;
}
long double solve(long double mi, long double ma) {
  long double ans = 0.0;
  long double ma0 = ma;
  for (int tt = 0; tt < (int)(74); tt++) {
    long double q = (mi + ma) * 0.5;
    long double mmi = 0.0;
    long double mma = 1e+4;
    long double cs = cosl(q);
    long double sn = sinl(q);
    tp pp;
    if (t2 < EPS) {
      pp.x = d02 - d02 * q / ma0;
      pp.y = 0.0;
    } else {
      for (int tt2 = 0; tt2 < (int)(123); tt2++) {
        long double qq = (mmi + mma) * 0.5;
        tp ppm;
        ppm.x = qq * cs;
        ppm.y = qq * sn;
        *(dist(p0, ppm) + dist(ppm, p2) <= d02 + t2 ? &mmi : &mma) = qq;
      }
      long double qq = (mmi + mma) * 0.5;
      pp.x = qq * cs;
      pp.y = qq * sn;
    }
    *(dist(p0, pp) + dist(pp, p1) <= d01 + t1 ? &ma : &mi) = q;
    if (dist(p0, pp) + dist(pp, p1) <= d01 + t1 + EPS2 &&
        dist(p0, pp) + dist(pp, p2) <= d02 + t2 + EPS2) {
      ans = max(ans, dist(p0, pp));
      long double d = 1e-5;
      tp pppp = pp;
      for (int ttt = 0; ttt < (int)(50); ttt++) {
        long double aa = 0.0;
        tp p;
        p = pp;
        for (long double a = 0.0; a <= 2.0 * PI; a += 6.14e-3) {
          long double cs = cos(a);
          long double sn = sin(a);
          tp pn;
          pn.x = pp.x + d * cs;
          pn.y = pp.y + d * sn;
          if (dist(p0, pn) + dist(pn, p1) <= d01 + t1 + 1e-17 &&
              dist(p0, pn) + dist(pn, p2) <= d02 + t2 + 1e-17) {
            if (dist2(p0, pn) > dist2(p0, p)) {
              p = pn;
              aa = a;
            }
          }
          pp = p;
        }
        d /= 1.1;
      }
      if (dist(pp, p0) < dist(pppp, p0) - 2e-11)
        for (;;)
          ;
    }
  }
  return ans;
}
int main() {
  cout << setiosflags(ios::fixed) << setprecision(10);
  cin >> t1 >> t2;
  cin >> p0.x >> p0.y;
  cin >> p2.x >> p2.y;
  cin >> p1.x >> p1.y;
  d01 = dist(p0, p1);
  d02 = dist(p0, p2);
  d12 = dist(p1, p2);
  if (d01 < 1e-7 || d02 < 1e-7 || d12 < 1e-7 || p0.x < -101.0 || p0.x > 101.0 ||
      p1.x < -101.0 || p1.x > 101.0 || p1.x < -101.0 || p1.x > 101.0 ||
      p0.y < -101.0 || p0.y > 101.0 || p1.y < -101.0 || p1.y > 101.0 ||
      p1.y < -101.0 || p1.y > 101.0)
    for (;;)
      ;
  if (d01 + d12 <= d02 + t2 + EPS) {
    cout << min(d01 + d12 + t1, d02 + t2) << endl;
  } else {
    long double ans = 0.0;
    if (d02 + d12 + d12 <= d01 + d12 + t1 + EPS) {
      long double dd = d01 + d12 + t1 - d02 - d12 - d12;
      ans = d02 + min(dd, t2);
      if (dd < t2) {
        ans = max(ans, d02 + dd + (t2 - dd) * 0.5);
      }
      cout << ans << endl;
      return 0;
    }
    p1.x -= p0.x;
    p1.y -= p0.y;
    p2.x -= p0.x;
    p2.y -= p0.y;
    p0.x = p0.y = 0.0;
    long double aa = atan2(p2.y, p2.x);
    rot(p1, -aa);
    rot(p2, -aa);
    if (p1.y < 0.0) p1.y *= -1;
    long double dt = (d01 + d12 + t1 - (d02 + t2)) * 0.5;
    tp pc;
    pc.x = p1.x + (p2.x - p1.x) / d12 * dt;
    pc.y = p1.y + (p2.y - p1.y) / d12 * dt;
    if (dist(p0, pc) + dist(pc, p1) <= d01 + t1 + EPS &&
        dist(p0, pc) + dist(pc, p2) <= d02 + t2 + EPS) {
      ans = d02 + t2 - dist(pc, p2);
      cout << ans << endl;
      return 0;
    }
    long double ma = fabs(atan2(p1.y, p1.x));
    long double mi = 0.0;
    const int SHA = 1;
    for (int ttt = 0; ttt < (int)(SHA); ttt++) {
      long double x1 = mi + (ma - mi) * ttt / SHA;
      long double x2 = mi + (ma - mi) * (ttt + 1) / SHA;
      ans = max(ans, solve(x1, x2));
    }
    cout << ans << endl;
  }
  return 0;
}