#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
int main() {
  long long ans = 0;
  int N, M;
  cin >> N >> M;
  int dist[100][100];
  vector<pair<pair<int, int>, int> > edge;
  for (int i = 0; i < 100; i++) {
    for (int j = 0; j < 100; j++) {
      dist[i][j] = INT_MAX / 2;
      if (i == j) {
        dist[i][j] = 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;
    edge.push_back(make_pair(make_pair(a, b), c));
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      for (int k = 0; k < N; k++) {
        dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
      }
    }
  }
  for (auto& e : edge) {
    int a = e.first.first;
    int b = e.first.second;
    int c = e.second;
    bool is_shortest = false;
    for (int i = 0; i < N; i++) {
      for (int j = i + 1; j < N; j++) {
        if (dist[i][j] == dist[i][a] + dist[b][j] + c) {
          is_shortest = true;
          break;
        }
      }
      if (is_shortest) {
        break;
      }
    }
    if (!is_shortest) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
