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>
T abs(T x) {
  return x > 0 ? x : -x;
}
int n;
int m;
vector<pair<double, double> > all;
double t1, t2, x0, y3487465, x1, y8687969, x2, y2, d01, d02, d12;
const double eps = 1e-11;
double dist(double x1, double y8687969, double x2, double y2) {
  return sqrt(((x2 - x1) * (x2 - x1)) + ((y2 - y8687969) * (y2 - y8687969)));
}
int cross(double x1, double y8687969, double r1, double x2, double y2,
          double r2) {
  double d = dist(x1, y8687969, x2, y2);
  if (d > r1 + r2 + eps) return 0;
  if (min(r1, r2) + d < max(r1, r2) - eps) return -1;
  double A = 2 * (x2 - x1);
  double B = 2 * (y2 - y8687969);
  double C =
      x1 * x1 + y8687969 * y8687969 - r1 * r1 - x2 * x2 - y2 * y2 + r2 * r2;
  double ax, ay, bx, by;
  if (fabs(A) > eps) {
    ay = 0;
    by = 1;
    ax = -C / A;
    bx = -(B + C) / A;
  } else {
    ax = 0;
    bx = 1;
    ay = -C / B;
    by = -(A + C) / B;
  }
  double dx = bx - ax, dy = by - ay;
  double a = dx * dx + dy * dy;
  double b = (2 * ax * dx - 2 * dx * x1 + 2 * ay * dy - 2 * dy * y8687969);
  double c = (ax * ax + x1 * x1 - 2 * ax * x1 + ay * ay + y8687969 * y8687969 -
              2 * ay * y8687969 - r1 * r1);
  d = b * b - 4 * a * c;
  if (d < -eps) return 0;
  if (fabs(d) < eps) d = 0;
  double t = (-b + sqrt(d)) / (2 * a);
  double xc1, yc1, xc2, yc2;
  xc1 = ax + dx * t;
  yc1 = ay + dy * t;
  t = (-b - sqrt(d)) / (2 * a);
  xc2 = ax + dx * t;
  yc2 = ay + dy * t;
  all.push_back(make_pair(xc1, yc1));
  all.push_back(make_pair(xc2, yc2));
  return 1;
}
int cross(double ax, double ay, double bx, double by, double x1,
          double y8687969, double r1) {
  double dx = bx - ax, dy = by - ay;
  double a = dx * dx + dy * dy;
  double b = (2 * ax * dx - 2 * dx * x1 + 2 * ay * dy - 2 * dy * y8687969);
  double c = (ax * ax + x1 * x1 - 2 * ax * x1 + ay * ay + y8687969 * y8687969 -
              2 * ay * y8687969 - r1 * r1);
  double d = b * b - 4 * a * c;
  if (d < -eps) return 0;
  if (fabs(d) < eps) d = 0;
  double t = (-b + sqrt(d)) / (2 * a);
  double xc1, yc1, xc2, yc2;
  xc1 = ax + dx * t;
  yc1 = ay + dy * t;
  t = (-b - sqrt(d)) / (2 * a);
  xc2 = ax + dx * t;
  yc2 = ay + dy * t;
  all.push_back(make_pair(xc1, yc1));
  all.push_back(make_pair(xc2, yc2));
  return 1;
}
int check(double R) {
  double r1 = d01 + t1 - R;
  double r2 = d02 + t2 - R;
  all.clear();
  int r12 = cross(x1, y8687969, r1, x2, y2, r2);
  int r01 = cross(x1, y8687969, r1, x0, y3487465, R);
  int r02 = cross(x2, y2, r2, x0, y3487465, R);
  if (r12 > 0)
    cross(all[0].first, all[0].second, all[1].first, all[1].second, x0,
          y3487465, R);
  if (r01 == -1 && r02 == -1 && r12 != 0) return 1;
  for (int i = 0; i < all.size(); i++) {
    double d0 = dist(x0, y3487465, all[i].first, all[i].second);
    double d1 = dist(x1, y8687969, all[i].first, all[i].second);
    double d2 = dist(x2, y2, all[i].first, all[i].second);
    if (d0 < R + eps && d1 < r1 + eps && d2 < r2 + eps) return 1;
  }
  return 0;
}
int main() {
  cin >> t2 >> t1 >> x0 >> y3487465 >> x1 >> y8687969 >> x2 >> y2;
  d01 = dist(x0, y3487465, x1, y8687969);
  d02 = dist(x0, y3487465, x2, y2);
  d12 = dist(x2, y2, x1, y8687969);
  double ans = 0;
  double l = 0, r = min(d01 + t1, d02 + t2);
  for (int it = 0; it < 200; it++) {
    double s = (l + r) / 2;
    if (check(s))
      l = s;
    else
      r = s;
  }
  ans = r;
  if (t1 + d01 + d12 < d02 + t2 + eps) ans = max(ans, d01 + t1);
  if (d02 + d12 < d01 + t1 + eps) ans = max(ans, min(d01 + t1, t2 + d02 + d12));
  printf("%.10f\n", (double)ans);
  return 0;
}