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 double eps = 1e-12;
const double pi = acos(-1);
struct Point {
  double x, y;
};
struct Circle {
  Point o;
  double r;
};
struct interval {
  double l, r;
};
Point operator-(Point p0, Point p1) {
  return (Point){p0.x - p1.x, p0.y - p1.y};
}
double dot(Point p0, Point p1) { return p0.x * p1.x + p0.y * p1.y; }
double norm(Point p) { return dot(p, p); }
double abs(Point p) { return sqrt(norm(p)); }
double angle(Point p) { return atan2(p.y, p.x); }
void read(Point& p) { scanf("%lf%lf", &p.x, &p.y); }
bool seperate(Circle c0, Circle c1) {
  return c0.r + c1.r + eps < abs(c0.o - c1.o);
}
bool contain(Circle c0, Circle c1) {
  return fabs(c0.r - c1.r) > abs(c0.o - c1.o);
}
interval get_interval(Circle c0, Circle c1) {
  double a = c0.r;
  double b = abs(c1.o - c0.o);
  double c = c1.r;
  double alpha = angle(c1.o - c0.o);
  double beta = acos((a * a + b * b - c * c) / (2 * a * b));
  return (interval){alpha - beta, alpha + beta};
}
bool intersect(interval i, double x) { return x >= i.l && x <= i.r; }
bool intersect(interval i0, interval i1) {
  if (intersect(i0, i1.l)) return true;
  if (intersect(i0, i1.r)) return true;
  if (intersect(i1, i0.l)) return true;
  if (intersect(i1, i0.r)) return true;
  return false;
}
bool intersect(Circle c0, Circle c1, Circle c2) {
  interval i0 = get_interval(c0, c1);
  interval i1 = get_interval(c0, c2);
  if (intersect(i0, i1)) return true;
  i0.l += 2 * pi;
  i0.r += 2 * pi;
  if (intersect(i0, i1)) return true;
  i0.l -= 4 * pi;
  i0.r -= 4 * pi;
  if (intersect(i0, i1)) return true;
  return false;
}
double T1, T2;
Point Cinema, House, Shop;
double dis1, dis2;
bool judge(double x) {
  Circle c0 = (Circle){Cinema, x};
  Circle c1 = (Circle){House, dis2 - x};
  Circle c2 = (Circle){Shop, dis1 - abs(Shop - House) - x};
  if (seperate(c0, c1)) return false;
  if (seperate(c0, c2)) return false;
  if (seperate(c1, c2)) return false;
  if (contain(c0, c1)) return true;
  if (contain(c0, c2)) return true;
  if (contain(c1, c2)) return true;
  if (intersect(c0, c1, c2)) return true;
  if (intersect(c1, c0, c2)) return true;
  if (intersect(c2, c0, c1)) return true;
  return false;
}
int main() {
  scanf("%lf%lf", &T1, &T2);
  read(Cinema);
  read(House);
  read(Shop);
  dis1 = T1 + abs(Cinema - Shop) + abs(Shop - House);
  dis2 = T2 + abs(Cinema - House);
  if (dis2 >= abs(Cinema - Shop) + abs(Shop - House)) {
    printf("%.10lf\n", min(dis1, dis2));
    return 0;
  }
  double l = 0, r = min(dis1 - abs(Shop - House), dis2);
  while (r - l > eps) {
    double mid = (r + l) / 2;
    if (judge(mid))
      l = mid;
    else
      r = mid;
  }
  printf("%.10lf\n", (l + r) / 2);
  return 0;
}