#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
vector<int> v;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  long long dis[105][105];
  for (int(i) = 0; (i) < (n); ++(i))
    for (int(j) = 0; (j) < (n); ++(j)) dis[i][j] = 1234567890;
  for (int(i) = 0; (i) < (n); ++(i)) dis[i][i] = 0;
  int aa[105], bb[105], cc[105];
  for (int(i) = 0; (i) < (m); ++(i)) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    aa[i] = a, bb[i] = b, cc[i] = c;
    dis[a][b] = c;
    dis[b][a] = c;
  }
  for (int(k) = 0; (k) < (n); ++(k))
    for (int(i) = 0; (i) < (n); ++(i))
      for (int(j) = 0; (j) < (n); ++(j)) {
        dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
      }
  long long count = 0;
  for (int(i) = 0; (i) < (m); ++(i))
    if (dis[aa[i]][bb[i]] != cc[i]) count++;
  cout << (count) << endl;
  return 0;
}
