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 <typename T>
void chmin(T &x, const T &y) {
  if (x > y) x = y;
}
template <typename T>
void chmax(T &x, const T &y) {
  if (x < y) x = y;
}
int read() {
  char c;
  while ((c = getchar()) < '-')
    ;
  if (c == '-') {
    int x = (c = getchar()) - '0';
    while ((c = getchar()) >= '0') x = x * 10 + c - '0';
    return -x;
  }
  int x = c - '0';
  while ((c = getchar()) >= '0') x = x * 10 + c - '0';
  return x;
}
const long double eps = 1e-12;
const long double I = sqrt(-1);
const pair<long double, long double> O = make_pair(0, 0);
int cmp(const long double &x) { return x < -eps ? -1 : x > eps; }
void read(pair<long double, long double> &p) { cin >> p.first >> p.second; }
pair<long double, long double> operator-(
    const pair<long double, long double> &p1,
    const pair<long double, long double> &p2) {
  return make_pair(p1.first - p2.first, p1.second - p2.second);
}
void operator-=(pair<long double, long double> &p1,
                const pair<long double, long double> &p2) {
  p1.first -= p2.first;
  p1.second -= p2.second;
}
long double sqr(const long double &x) { return x * x; }
long double dis2(pair<long double, long double> p1,
                 pair<long double, long double> p2 = O) {
  return sqr(p1.first - p2.first) + sqr(p1.second - p2.second);
}
long double dis(pair<long double, long double> p1,
                pair<long double, long double> p2 = O) {
  return sqrt(sqr(p1.first - p2.first) + sqr(p1.second - p2.second));
}
pair<long double, long double> a, b, c;
long double t1, t2;
void jie(long double &x1, long double &x2, long double a, long double b,
         long double c) {
  long double s = -b / (2 * a), d = cmp(b * b - 4 * a * c) <= 0
                                        ? 0
                                        : sqrt(b * b - 4 * a * c) / (2 * a);
  x1 = s - d;
  x2 = s + d;
}
bool ok(pair<long double, long double> B, long double l1,
        pair<long double, long double> C, long double l2, long double l) {
  if (cmp(l1 - dis(B) - l) >= 0) return 1;
  if (cmp(l - dis(B) - l1) >= 0) return 1;
  long double a = 2 * B.first, b = 2 * B.second,
              c = sqr(l1) - sqr(l) - sqr(B.first) - sqr(B.second);
  long double x1, x2, y1, y2;
  if (!cmp(b)) {
    x1 = x2 = -c / a;
    if (cmp(sqr(l) - sqr(x1)) <= 0) {
      y1 = y2 = 0;
    } else {
      y1 = sqrt(sqr(l) - sqr(x1));
      y2 = -y1;
    }
  } else {
    a = -a / b;
    c = -c / b;
    jie(x1, x2, 1 + sqr(a), 2 * a * c, sqr(c) - sqr(l));
    y1 = a * x1 + c;
    y2 = a * x2 + c;
  }
  return cmp(dis(C, make_pair(x1, y1)) - l2) <= 0 ||
         cmp(dis(C, make_pair(x2, y2)) - l2) <= 0;
}
bool ok(const long double &l) {
  long double l2 = t2 - l, l1 = t1 - l;
  if (cmp(sqr(l1 + l2) - dis2(b, c)) < 0) return 0;
  return ok(b, l1, c, l2, l) || ok(c, l2, b, l1, l) ||
         ok(b - c, l1, O - c, l, l2);
}
int main() {
  cin >> t2 >> t1;
  read(a);
  read(b);
  read(c);
  b -= a;
  c -= a;
  t1 += dis(b);
  t2 += dis(c);
  if (cmp(dis(c) + dis(b, c) - t1) <= 0) {
    printf("%lf\n", (double)min(t2 + dis(b, c), t1));
    return 0;
  }
  long double l = 0, r = min(t1, t2);
  for (int o = 1; o <= 40; ++o) {
    long double mid = (l + r) / 2;
    if (ok(mid))
      l = mid;
    else
      r = mid;
  }
  printf("%lf\n", (double)l);
}