#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const long long MOD = 1000000007;
template <class T>
void warshall_floyd(T &dis) {
  int V = dis.size();
  for (int k = 0; k < (int)(V); k++)
    for (int i = 0; i < (int)(V); i++) {
      if (dis[i][k] == INF) continue;
      for (int j = 0; j < (int)(V); j++) {
        if (dis[k][j] == INF) continue;
        dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
      }
    }
}
int main() {
  int N, M;
  cin >> N >> M;
  vector<tuple<int, int, int>> edge(M);
  vector<vector<long long>> dis(N, vector<long long>(N, INF));
  for (int i = 0; i < (int)(N); i++) dis[i][i] = 0;
  for (int i = 0; i < (int)(M); i++) {
    int a, b, c;
    cin >> a >> b >> c, a--, b--;
    edge[i] = make_tuple(a, b, c);
    dis[a][b] = c;
    dis[b][a] = c;
  }
  warshall_floyd(dis);
  long long ans = 0;
  for (int i = 0; i < (int)(M); i++) {
    int a = get<0>(edge[i]), b = get<1>(edge[i]), c = get<2>(edge[i]);
    bool ok = false;
    for (int j = 0; j < (int)(N); j++) {
      for (int k = j + 1; k < N; k++) {
        if (dis[j][a] + c + dis[b][k] == dis[j][k]) ok = true;
      }
    }
    if (!ok) ans++;
  }
  cout << ans << endl;
}
