#include <bits/stdc++.h>
using namespace std;
const int mod1 = 998244353, mod = 1e9 + 7;
const int MAXN = 100005, MAXM = 200010;
const long long MX = 20;
long long dp[MX][1 << MX], cost[1 << MX], adj[MX][MX];
long long n, m;
void Solve() {
  cin >> n >> m;
  for (long long i = 1, u, v, w; i <= m; i++) {
    cin >> u >> v >> w;
    u--;
    v--;
    adj[u][v] = adj[v][u] = w;
  }
  for (long long mask = 1; mask < (1 << n); mask++) {
    for (long long i = 0; i < n; i++) {
      for (long long j = i + 1; j < n; j++) {
        if (((mask >> i) & 1) && ((mask >> j) & 1)) {
          cost[mask] += adj[i][j];
        }
      }
      dp[i][mask] = -1;
    }
  }
  dp[0][1] = 0;
  for (long long mask = 1; mask < (1 << n); mask++) {
    for (long long i = 0; i < n; i++) {
      if (~dp[i][mask]) {
        for (long long j = 0; j < n; j++) {
          if (!((mask >> j) & i) && adj[i][j]) {
            dp[j][mask | (1 << j)] =
                max(dp[j][mask | (1 << j)], dp[i][mask] + adj[i][j]);
          }
        }
        long long left = ((1 << n) - 1) ^ mask;
        for (long long nxt = left; nxt; nxt = (nxt - 1) & left) {
          dp[i][mask | nxt] =
              max(dp[i][mask | nxt], dp[i][mask] + cost[nxt | (1 << i)]);
        }
      }
    }
  }
  cout << cost[(1 << n) - 1] - dp[n][(1 << n) - 1];
}
signed main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long TC = 1;
  while (TC--) Solve();
  return 0;
}
