#include <bits/stdc++.h>
using namespace std;
typedef vector<vector<int> > Matrix;
const int INF = 1000000000;
Matrix dist;
bool warshall_floyd(int n) {
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (dist[i][k] != INF && dist[k][j] != INF) {
          dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (dist[i][i] < 0) return true;
  }
  return false;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  dist = Matrix(n, vector<int>(n, INF));
  Matrix g(n, vector<int>(n, INF));
  for (int i = 0; i < n; i++) {
    dist[i][i] = 0;
    g[i][i] = 0;
  }
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    dist[a][b] = c;
    dist[b][a] = c;
    g[a][b] = c;
    g[b][a] = c;
  }
  warshall_floyd(n);
  set<pair<int, int> > s;
  for (int t = 1; t < n; t++) {
    for (int f = 0; f < t; f++) {
      int cur = f;
      while (cur != t) {
        for (int i = 0; i < n; i++) {
          if (i == cur) continue;
          if (g[cur][i] == INF) continue;
          if (dist[cur][i] == INF) continue;
          if (dist[cur][t] == INF) continue;
          if (g[cur][i] + dist[i][t] == dist[cur][t]) {
            if (cur > i)
              s.insert(pair<int, int>(i, cur));
            else
              s.insert(pair<int, int>(cur, i));
            cur = i;
            break;
          }
        }
      }
    }
  }
  cout << m - s.size() << endl;
  return 0;
}
