#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N;
  cin >> N;
  long long M;
  cin >> M;
  long long ans = 0;
  vector<vector<long long>> dist(N, vector<long long>(N, 1000000001));
  for (int(i) = int(0); (i) < int(N); (i)++) {
    dist[i][i] = 0;
  }
  vector<pair<long long, pair<long long, long long>>> data(M);
  for (int(i) = int(0); (i) < int(M); (i)++) {
    long long a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    data[i].first = c;
    data[i].second.first = a;
    data[i].second.second = b;
    dist[a][b] = c;
    dist[b][a] = c;
  }
  for (int(k) = int(0); (k) < int(N); (k)++) {
    for (int(i) = int(0); (i) < int(N); (i)++) {
      for (int(j) = int(0); (j) < int(N); (j)++) {
        dist[i][j] = ((dist[i][j]) < (dist[i][k] + dist[k][j])
                          ? (dist[i][j])
                          : (dist[i][k] + dist[k][j]));
      }
    }
  }
  for (int(x) = int(0); (x) < int(N); (x)++) {
    vector<vector<long long>> buf(N, vector<long long>(N, 1000000001));
    for (int(i) = int(0); (i) < int(N); (i)++) {
      buf[i][i] = 0;
    }
    for (int(i) = int(0); (i) < int(M); (i)++) {
      if (i != x) {
        buf[data[i].second.first][data[i].second.second] = data[i].first;
        buf[data[i].second.second][data[i].second.first] = data[i].first;
      }
    }
    for (int(k) = int(0); (k) < int(N); (k)++) {
      for (int(i) = int(0); (i) < int(N); (i)++) {
        for (int(j) = int(0); (j) < int(N); (j)++) {
          buf[i][j] =
              ((buf[i][j]) < (buf[i][k] + buf[k][j]) ? (buf[i][j])
                                                     : (buf[i][k] + buf[k][j]));
        }
      }
    }
    long long ok = 0;
    for (int(i) = int(0); (i) < int(N); (i)++) {
      for (int(j) = int(0); (j) < int(N); (j)++) {
        if (buf[i][j] != dist[i][j]) {
          ans += 1;
          ok = 1;
          break;
        }
      }
      if (ok == 1) {
        break;
      }
    }
  }
  cout << (M - ans) << endl;
  return 0;
}
