#include <bits/stdc++.h>
using namespace std;
const long long SZ = (2 << 16), LG = 18, INF = 1e9 * 1e6;
long long n, m;
long long grid[LG][LG], inter[SZ], dp[SZ], mx[SZ];
int main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(0);
  ;
  cin >> n >> m;
  for (int i = 0; i < LG; i++) {
    for (int j = 0; j < LG; j++) grid[i][j] = INF;
  }
  long long sum = 0;
  for (int i = 0; i < m; i++) {
    long long u, v, c;
    cin >> u >> v >> c;
    sum += c;
    u--;
    v--;
    grid[u][v] = c;
    grid[v][u] = c;
  }
  long long pw = (1ll << n);
  for (int i = 0; i < pw; i++) {
    long long cur = 0;
    for (int j = 0; j < n; j++) {
      for (int k = j + 1; k < n; k++) {
        if (((i >> k) & 1) && ((i >> j) & 1) && grid[k][j] != INF) {
          cur += grid[k][j];
        }
      }
    }
    inter[i] = cur;
  }
  for (int i = 0; i < pw; i++) {
    for (int j = 0; j < LG; j++) dp[i] = -INF;
  }
  for (int i = 0; i < LG; i++) dp[(1ll << i)] = 0;
  dp[1] = 0;
  for (int i = 2; i < pw; i++) {
    for (int j = 0; j < LG; j++) {
      for (int k = 0; k < LG; k++) {
        if (j != k && (i & (1ll << k)) && (i & (1ll << j)) &&
            grid[j][k] != INF) {
          long long msk = i ^ (1ll << j);
          dp[i] = max(dp[i], dp[msk] + grid[k][j]);
        }
      }
    }
  }
  long long ans = -INF;
  for (int i = 0; i < pw; i++) {
    if (!(i & 1)) continue;
    if (!((i >> (n - 1)) & 1)) continue;
    long long inv = ((pw - 1) ^ i);
    for (int sub = inv; true; sub = ((sub - 1) & inv)) {
      int sub2 = (inv ^ sub);
      long long vl1 = inter[sub | (1ll)] + inter[sub2 | (1ll << (n - 1))],
                vl2 = inter[sub | (1ll << (n - 1))] + inter[sub2 | (1ll)];
      ans = max(ans, dp[i] + vl1);
      ans = max(ans, dp[i] + vl2);
      if (sub == 0) break;
    }
  }
  cout << sum - ans;
  return 0;
}
