#include <bits/stdc++.h>

using namespace std;

const int INF = 1 << 30;

int N, M;
int g[17][17];
int lookup[1 << 17];
int dp[1 << 17][16];
vector< int > add[1 << 17];

int rec(int mask, int pre)
{
  if(mask == 0) return (0);
  if(~dp[mask][pre]) return (dp[mask][pre]);
  int ret = -INF;
  for(int i = mask; i > 0; i = (i - 1) & mask) {
    for(auto &j : add[i]) {
      if(pre != 15 && g[pre][j] == 0) continue;
      ret = max(ret, rec(mask ^ i, j) + lookup[i] + g[pre][j]);
    }
  }
  return (dp[mask][pre] = ret);
}

signed main()
{
  memset(dp, -1, sizeof(dp));

  cin >> N >> M;
  int all = 0;

  for(int i = 0; i < M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    --a, --b;
    g[a][b] = c;
    g[b][a] = c;
    all += c;
  }

  for(int i = 0; i < 1 << N; i++) {
    if(i & 1 && (i >> (N - 1)) & 1) continue;
    for(int j = 0; j < N; j++) {
      if((i >> j) & 1) {
        if(i & 1) {
          if(j == 0) add[i].push_back(j);
        } else if((i >> (N - 1)) & 1) {
          if(j == N - 1) add[i].push_back(j);
        } else {
          add[i].push_back(j);
        }
        for(int k = j + 1; k < N; k++) {
          if((i >> k) & 1) lookup[i] += g[j][k];
        }
      }
    }
  }
  cout << all - rec((1 << N) - 1, 15) << endl;
}