#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  } else {
    return 0;
  }
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  } else {
    return 0;
  }
}
template <class T>
inline T GCD(T a, T b) {
  T c;
  while (b != 0) {
    c = a % b;
    a = b;
    b = c;
  }
  return a;
}
template <class T>
inline T LCM(T a, T b) {
  return a * b / GCD(a, b);
}
vector<pair<int, int>> g[110];
int dist[110][110];
void dijkstra(int n) {
  for (int i = 0; i < (105); i++) {
    dist[n][i] = 1000000007;
  }
  priority_queue<pair<int, int>> v;
  v.push(make_pair(0, n));
  while (!v.empty()) {
    pair<int, int> a = v.top();
    v.pop();
    if (dist[n][a.second] < a.first) continue;
    dist[n][a.second] = a.first;
    for (int i = 0; i < (g[a.second].size()); i++) {
      v.push(make_pair(a.first + g[a.second][i].second, g[a.second][i].first));
    }
  }
  return;
}
int main() {
  int n, m;
  cin >> n >> m;
  int a, b, c;
  for (int i = 0; i < (m); i++) {
    cin >> a >> b >> c;
    g[a].push_back(make_pair(b, c));
    g[b].push_back(make_pair(a, c));
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    dijkstra(i);
    for (int j = 0; j < (g[i].size()); j++) {
      if (g[i][j].second > dist[i][g[i][j].first]) ans++;
    }
  }
  ans /= 2;
  cout << ans << endl;
}
