#include <bits/stdc++.h>
using namespace std;
vector<vector<long long>> dist(105, vector<long long>(105, 1000000001));
vector<long long> ina;
vector<long long> inb;
long long N;
long long check(long long a, long long b, vector<vector<long long>> buf) {
  buf[a][b] = 1000000001;
  buf[b][a] = 1000000001;
  for (long long(k) = long long(0); (k) < long long(N); (k)++) {
    for (long long(i) = long long(0); (i) < long long(N); (i)++) {
      for (long long(j) = long long(0); (j) < long long(N); (j)++) {
        buf[i][j] =
            ((buf[i][j]) < (buf[i][k] + buf[k][j]) ? (buf[i][j])
                                                   : (buf[i][k] + buf[k][j]));
      }
    }
  }
  for (long long(i) = long long(0); (i) < long long(N); (i)++) {
    for (long long(j) = long long(0); (j) < long long(N); (j)++) {
      if (i == j) {
        continue;
      }
      if (buf[i][j] > dist[i][j]) {
        return 0;
      } else {
      }
    }
  }
  return 1;
}
int main() {
  cin >> N;
  long long M;
  cin >> M;
  vector<vector<long long>> calc(105, vector<long long>(105, 1000000001));
  for (long long(i) = long long(0); (i) < long long(M); (i)++) {
    long long a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    dist[a][b] = c;
    dist[b][a] = c;
    calc[a][b] = c;
    calc[b][a] = c;
    ina.emplace_back(a);
    inb.emplace_back(b);
  }
  for (long long(k) = long long(0); (k) < long long(N); (k)++) {
    for (long long(i) = long long(0); (i) < long long(N); (i)++) {
      for (long long(j) = long long(0); (j) < long long(N); (j)++) {
        dist[i][j] = ((dist[i][j]) < (dist[i][k] + dist[k][j])
                          ? (dist[i][j])
                          : (dist[i][k] + dist[k][j]));
      }
    }
  }
  long long ans = 0;
  for (long long(ii) = long long(0); (ii) < long long(M); (ii)++) {
    ans += check(ina[ii], inb[ii], calc);
  }
  cout << (ans) << endl;
  return 0;
}
