#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;
int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> d(N, vector<int>(N, INF));
  map<pair<int, int>, bool> used;
  for (int i = 0; i < (M); ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    d[a][b] = d[b][a] = c;
    if (a > b) swap(a, b);
    used[pair<int, int>(a, b)] = false;
  }
  for (int i = 0; i < (N); ++i) d[i][i] = 0;
  for (int k = 0; k < (N); ++k) {
    for (int i = 0; i < (N); ++i) {
      for (int j = 0; j < (N); ++j) {
        if (d[i][k] + d[k][j] < d[i][j]) {
          d[i][j] = d[i][k] + d[k][j];
          int a = i, b = k;
          if (a > b) swap(a, b);
          used[pair<int, int>(a, b)] = true;
          a = k, b = j;
          if (a > b) swap(a, b);
          used[pair<int, int>(a, b)] = true;
        }
      }
    }
  }
  int ans = 0;
  for (auto p : used) {
    if (!p.second) ans++;
  }
  cout << ans << endl;
}
