#include <bits/stdtr1c++.h>

using namespace std;

struct edge {
	int v, w;
};

int n, m, memo[20][1<<18];
vector<edge> g[20];
int dp(int i, int bs) {
	if (i == n-1) return 0;
	if (memo[i][bs] != -1) return memo[i][bs];
	
	int& ans = memo[i][bs] = -1000000;
	for (auto e : g[i]) {
		int j = e.v;
		if ( (bs & (1<<j)) == 0 ) {
			ans = max(ans, e.w + dp(j, bs | (1<<j)));
		}
	}
	return ans;
}

int main() {
	memset(memo, -1, sizeof memo);
	
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int u, v, w; cin >> u >> v >> w;
		g[u].push_back({v, w});
		//g[v].push_back({u, w});
	}
	
	/*
	for (int i = 0; i < n; i++) {
		g[19].push_back({i, 0});
	}*/
	
	cout << dp(0, 1) << endl;
	
	return 0;
}