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-10;
struct Point {
  long double x, y;
};
Point operator+(Point a, Point b) {
  a.x += b.x;
  a.y += b.y;
  return a;
}
Point operator-(Point a, Point b) {
  a.x -= b.x;
  a.y -= b.y;
  return a;
}
long double len(Point p) { return sqrt(p.x * p.x + p.y * p.y); }
Point operator*(long double k, Point a) {
  a.x *= k;
  a.y *= k;
  return a;
}
Point ortho(Point a) {
  Point b;
  b.x = a.y;
  b.y = -a.x;
  return b;
}
vector<Point> getIntersection(Point A, Point B, long double R1,
                              long double R2) {
  vector<Point> ans;
  long double d = len(A - B);
  long double x = (d * d + R1 * R1 - R2 * R2) / (2 * d);
  if (abs(abs(x) - R1) < EPS) x = R1;
  if (R1 < abs(x)) return ans;
  long double y = sqrt(R1 * R1 - x * x);
  Point V = B - A;
  V.x /= d;
  V.y /= d;
  Point m = A + x * V;
  ans.push_back(m + y * ortho(V));
  ans.push_back(m + (-y) * ortho(V));
  return ans;
}
Point A, B, C;
long double RA, RB, RC;
bool inside(Point p) {
  if (len(p - A) > RA + EPS) return false;
  if (len(p - B) > RB + EPS) return false;
  if (len(p - C) > RC + EPS) return false;
  return true;
}
int main() {
  long double t1, t2;
  ignore = scanf("%Lf %Lf", &t1, &t2);
  ignore = scanf("%Lf %Lf", &B.x, &B.y);
  ignore = scanf("%Lf %Lf", &A.x, &A.y);
  ignore = scanf("%Lf %Lf", &C.x, &C.y);
  long double T1 = t1 + len(C - B) + len(C - A);
  long double T2 = t2 + len(B - A);
  if (T2 >= len(B - C) + len(C - A)) {
    printf("%.15Lf", min(T1, T2));
    return 0;
  }
  long double L = 0, R = min(T2, len(B - C) + t1);
  for (int it = 0; it < 1000; it++) {
    double l = (L + R) / 2.0;
    RA = len(A - B) + t2 - l;
    RB = l;
    RC = len(B - C) + t1 - l;
    vector<Point> pts;
    vector<Point> tmp = getIntersection(A, B, RA, RB);
    for (Point p : tmp) pts.push_back(p);
    tmp = getIntersection(A, C, RA, RC);
    for (Point p : tmp) pts.push_back(p);
    tmp = getIntersection(B, C, RB, RC);
    for (Point p : tmp) pts.push_back(p);
    pts.push_back(A);
    pts.push_back(B);
    pts.push_back(C);
    bool ok = false;
    for (Point p : pts) {
      if (inside(p)) {
        ok = true;
        break;
      }
    }
    if (ok)
      L = l;
    else
      R = l;
  }
  printf("%.15Lf", R);
}