#include <bits/stdc++.h>
using namespace std;
struct UnionFind {
  int size;
  vector<int> parent;
  UnionFind() {}
  UnionFind(int size) {
    this->size = size;
    parent.resize(size + 1);
    init();
  }
  void init() {
    for (int i = 0; i <= size; i++) parent[i] = i;
  }
  int root(int i) {
    if (parent[i] == i) return i;
    return parent[i] = root(parent[i]);
  }
  bool same(int i, int j) { return root(i) == root(j); }
  void unite(int i, int j) {
    int root_i = root(i), root_j = root(j);
    if (root_i == root_j) return;
    parent[root_i] = root_j;
  }
};
long long n, m;
vector<pair<long long, pair<long long, long long> > > vec;
long long mst[1 << 15];
UnionFind uf(25);
int main(void) {
  cin >> n >> m;
  long long u, v, w, sum = 0;
  for (int i = 0; i < m; i++) {
    cin >> u >> v >> w;
    u--, v--;
    vec.push_back(make_pair(w, make_pair(u, v)));
    sum += w;
  }
  sort(vec.rbegin(), vec.rend());
  long long N = 1 << n;
  for (int i = 0; i < N; i++) {
    mst[i] = -1;
    if ((i & 1) == 0 || (i & (1 << (n - 1))) == 0) continue;
    for (int j = i; j > 0; j = (j - 1) & i) {
      if ((j & 1) == 0 || (j & (1 << (n - 1))) == 0) continue;
      int cnt = 0;
      for (int k = 0; k < n; k++)
        if (j & (1 << k)) cnt++;
      uf.init();
      long long tmp = 0;
      for (int k = 0; k < vec.size(); k++) {
        long long u = vec[k].second.first, v = vec[k].second.second,
                  w = vec[k].first;
        if ((j & (1 << u)) == 0 || (j & (1 << v)) == 0) continue;
        if (uf.same(u, v)) continue;
        tmp += w;
        uf.unite(u, v);
        cnt--;
      }
      if (cnt > 1) continue;
      for (int k = 0; k < n; k++)
        if ((i & (1 << k)) && (j & (1 << k)) == 0) cnt++;
      for (int k = 0; k < vec.size(); k++) {
        long long u = vec[k].second.first, v = vec[k].second.second,
                  w = vec[k].first;
        if ((i & (1 << u)) == 0 || (i & (1 << v)) == 0) continue;
        if (uf.same(u, v) && ((j & (1 << u)) || (j & (1 << v)))) continue;
        tmp += w;
        uf.unite(u, v);
        cnt--;
      }
      if (cnt == 1) mst[i] = max(mst[i], tmp);
    }
  }
  long long ans = 0;
  for (int i = 0; i < N; i++) {
    if (mst[i] < 0 || (i & 1) == 0 || (i & (1 << (n - 1))) == 0) continue;
    int U = (N - 1) - i;
    for (int j = U;; j = (j - 1) & U) {
      int S = j, T = U - S;
      S |= 1, T |= 1 << (n - 1);
      uf.init();
      long long tmp = 0;
      for (int k = 0; k < vec.size(); k++) {
        long long u = vec[k].second.first, v = vec[k].second.second,
                  w = vec[k].first;
        if ((S & (1 << u)) && (S & (1 << v)))
          uf.unite(u, v), tmp += w;
        else if ((T & (1 << u)) && (T & (1 << v)))
          uf.unite(u, v), tmp += w;
      }
      bool flag = true;
      for (int k = 0; k < n; k++) {
        if ((S & (1 << k)) == 0) continue;
        if (uf.root(k) != uf.root(0)) flag = false;
      }
      for (int k = 0; k < n; k++) {
        if ((T & (1 << k)) == 0) continue;
        if (uf.root(k) != uf.root(n - 1)) flag = false;
      }
      if (flag) ans = max(ans, mst[i] + tmp);
      if (j == 0) break;
    }
  }
  ans = sum - ans;
  cout << ans << endl;
  return 0;
}
