#include <bits/stdc++.h>
using namespace std;
int dijkstra(int a, int b, int (&map)[101][101], int N) {
  priority_queue<pair<int, int>> Q;
  int d[101];
  bool chk[101];
  for (int i = 0; i < N; i++) {
    if (i == a)
      d[i] = 0;
    else
      d[i] = 1000001;
    Q.push(make_pair(-d[i], i));
    chk[i] = false;
  }
  while (!Q.empty()) {
    pair<int, int> t = Q.top();
    Q.pop();
    if (chk[t.second]) continue;
    chk[t.second] = true;
    if (t.first == -1000001) break;
    for (int i = 1; i <= N; i++) {
      if (map[t.second][i] != 0) {
        int alt = d[t.second] + map[t.second][i];
        if (d[i] > alt) {
          d[i] = alt;
          Q.push(make_pair(-alt, i));
        }
      }
    }
  }
  return d[b];
}
int main() {
  int N, M;
  cin >> N >> M;
  int map[101][101];
  for (int i = 0; i <= 100; i++) {
    for (int j = 0; j <= 100; j++) {
      map[i][j] = 0;
    }
  }
  queue<pair<int, int>> edge;
  for (int i = 0; i < M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    map[a][b] = map[b][a] = c;
    edge.push(make_pair(a, b));
  }
  int result = 0;
  while (!edge.empty()) {
    int a, b;
    a = edge.front().first;
    b = edge.front().second;
    if (map[a][b] > dijkstra(a, b, map, N)) {
      result++;
    }
    edge.pop();
  }
  cout << result << endl;
  return 0;
}
