#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1000000007;
long long int power(long long int x, long long int n, long long int M) {
  long long int tmp = 1;
  if (n > 0) {
    tmp = power(x, n / 2, M);
    if (n % 2 == 0)
      tmp = (tmp * tmp) % M;
    else
      tmp = (((tmp * tmp) % M) * x) % M;
  }
  return tmp;
}
long long int N, M, K, Q, W, H, L, R;
long long int ans;
int main() {
  ios::sync_with_stdio(false);
  int num[101][101] = {};
  bool used[101][101] = {};
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    num[a][b] = c;
    num[b][a] = c;
  }
  priority_queue<pair<int, int>> PQ;
  for (int i = 1; i <= N; i++) {
    vector<int> dis(N + 1, INT_MAX);
    dis[i] = 0;
    PQ.push({0, i});
    while (!PQ.empty()) {
      int c = PQ.top().first;
      int cn = PQ.top().second;
      PQ.pop();
      if (dis[cn] < c) continue;
      dis[cn] = c;
      for (int j = 1; j <= N; j++) {
        if (num[cn][j]) {
          if (dis[j] > dis[i] + num[cn][j]) {
            dis[j] = dis[i] + num[cn][j];
            PQ.push({dis[j], j});
          }
        }
      }
    }
    for (int j = i + 1; j <= N; j++) {
      queue<int> QQ;
      QQ.push(j);
      while (!QQ.empty()) {
        int c = QQ.front();
        for (int k = 1; k <= N; k++) {
          if (num[c][k]) {
            if (dis[c] == dis[k] + num[k][c]) {
              QQ.push(k);
              used[c][k] = true;
              used[k][c] = true;
            }
          }
        }
        QQ.pop();
      }
    }
  }
  for (int i = 1; i <= N; i++) {
    for (int j = i + 1; j <= N; j++) {
      if (num[i][j] && !used[i][j]) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
