#include using namespace std; #define rep(i,n) for(int i = 0; i < (n);i++) #define sz(x) int(x.size()) typedef long long ll; typedef pair P; int main(){ int n, m; cin >> n >> m; vector> it(n, vector(n,0)); rep(i,m) { int a, b, c; cin >> a >> b >> c; it[a][b] = c; } vector idx; rep(i,n) idx.push_back(i); int res = 0; do { int tmp = 0; rep(i,n-1) tmp += it[idx[i]][idx[i+1]]; res = max(res, tmp); } while (next_permutation(idx.begin(), idx.end())); cout << res << endl; return 0; }