#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf = 1001001001;
map<P, int> mp;
vector<vector<int>> h, g;
vector<int> restore_path(int start, int end, int n) {
  vector<int> p;
  int curr = start;
  while (curr != end) {
    for (int i = 1; i <= n; i++) {
      if (i != curr && h[curr][i] + g[i][end] == g[curr][end]) {
        if (curr < i)
          mp[P{curr, i}] = 1;
        else
          mp[P{i, curr}] = 1;
        curr = i;
        p.push_back(i);
      }
    }
  }
  return p;
}
int main() {
  int n, m;
  cin >> n >> m;
  h.resize(n + 1);
  for (int i = 0; i < (n); i++) h[i + 1].resize(n + 1);
  for (int i = 0; i < (n); i++) {
    for (int j = 0; j < (n); j++) {
      if (i == j)
        h[i + 1][j + 1] = 0;
      else
        h[i + 1][j + 1] = inf;
    }
  }
  for (int i = 0; i < (m); i++) {
    int a, b, c;
    cin >> a >> b >> c;
    h[a][b] = h[b][a] = c;
  }
  g = h;
  for (int k = 1; k <= n; k++) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
      }
    }
  }
  vector<int> it = restore_path(1, 2, n);
  cout << m - (int)mp.size();
}
