#include <bits/stdc++.h>
const long long INF = LLONG_MAX / 2;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
using namespace std;
string s;
vector<long long int> v;
vector<pair<long long int, long long int>> vp;
vector<vector<long long int>> vv(110, vector<long long int>(110, INF));
vector<tuple<long long int, long long int, long long int>> vt;
set<long long int> st;
map<char, long long int> mp;
struct Edge {
  int from, to;
  int cost;
  bool operator<(const Edge& e) const { return cost < e.cost; }
  bool operator>(const Edge& e) const { return cost > e.cost; }
};
void add_edge(vector<vector<Edge>>& g, int from, int to, int cost) {
  g[from].push_back(Edge{from, to, cost});
}
int main() {
  long long int n, m, cnt = 0;
  cin >> n >> m;
  set<pair<long long int, long long int>> elist, anslist;
  for (int i = (long long int)((0)); i < (long long int)(m); i++) {
    long long int a, b, c;
    cin >> a >> b >> c;
    vv[a][b] = vv[b][a] = c;
    elist.emplace(a, b);
    elist.emplace(b, a);
  }
  for (int k = (long long int)((0)); k < (long long int)(n); k++)
    for (int i = (long long int)((0)); i < (long long int)(n); i++) {
      for (int j = (long long int)((0)); j < (long long int)(n); j++) {
        if (vv[i][j] > vv[i][k] + vv[k][j]) {
          vv[i][j] = vv[i][k] + vv[k][j];
          if (elist.count(make_pair(i, k))) anslist.emplace(i, k);
          if (elist.count(make_pair(k, j))) anslist.emplace(k, j);
        }
      }
    }
  cout << m - anslist.size() << endl;
}
