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;
int t1, t2;
struct point {
  double x, y;
  point() {}
  point(double x1, double y1) {
    x = x1;
    y = y1;
  }
} A, B, C, O;
struct Tprogram {
  void open() {
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
  }
  void close() {}
  double dis(point &A, point &B) {
    return sqrt(((A.x - B.x) * (A.x - B.x)) + ((A.y - B.y) * (A.y - B.y)));
  }
  void init() {
    scanf("%d%d", &t1, &t2);
    scanf("%lf%lf", &A.x, &A.y);
    scanf("%lf%lf", &C.x, &C.y);
    scanf("%lf%lf", &B.x, &B.y);
  }
  void get(double thi, double tmp, vector<point> &g) {
    tmp = (tmp < 1 ? tmp : 1);
    tmp = (tmp > -1 ? tmp : -1);
    tmp = acos(tmp);
    g.clear();
    double l = thi - tmp, r = thi + tmp;
    if (l < -3.1415926535897)
      g.push_back(point(l + 2 * 3.1415926535897, 3.1415926535897)),
          g.push_back(point(-3.1415926535897, r));
    else if (r > 3.1415926535897)
      g.push_back(point(l, 3.1415926535897)),
          g.push_back(point(-3.1415926535897, r - 2 * 3.1415926535897));
    else
      g.push_back(point(l, r));
  }
  bool Check(point A, double r, point B, double rb, point C, double rc) {
    B.x -= A.x;
    B.y -= A.y;
    C.x -= A.x;
    C.y -= A.y;
    vector<point> g1, g2;
    double d = dis(B, O);
    if (d > r + rb + 1e-12 || d < r - rb) return 0;
    if (d < fabs(r - rb))
      get(0, -1, g1);
    else
      get(atan2(B.y, B.x), (d * d + r * r - rb * rb) / (2 * r * d), g1);
    d = dis(C, O);
    if (d > r + rc + 1e-12 || d < r - rc) return 0;
    if (d < fabs(r - rc))
      get(0, -1, g2);
    else
      get(atan2(C.y, C.x), (d * d + r * r - rc * rc) / (2 * r * d), g2);
    for (int i = 1; i <= g1.size(); i++)
      for (int j = 1; j <= g2.size(); j++)
        if ((g1[i - 1].x > g2[j - 1].x ? g1[i - 1].x : g2[j - 1].x) <=
            (g1[i - 1].y < g2[j - 1].y ? g1[i - 1].y : g2[j - 1].y))
          return 1;
    return 0;
  }
  void work() {
    if (dis(A, B) + dis(B, C) <= dis(A, C) + t2) {
      printf("%lf\n", (dis(A, B) + dis(B, C) + t1 < dis(A, C) + t2
                           ? dis(A, B) + dis(B, C) + t1
                           : dis(A, C) + t2));
    } else {
      double d1 = dis(A, B) + t1, d2 = dis(A, C) + t2;
      double l = 0, r = (d1 < d2 ? d1 : d2);
      for (int i = 1; i <= 100; i++) {
        double m = (l + r) / 2;
        if (Check(A, m, B, d1 - m, C, d2 - m) ||
            Check(B, d1 - m, A, m, C, d2 - m) ||
            Check(C, d2 - m, B, d1 - m, A, m))
          l = m;
        else
          r = m;
      }
      printf("%lf\n", l);
    }
  }
} Program;
int main() {
  Program.init();
  Program.work();
  return 0;
}