#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<pair<int, int> > e[111];
int f[111][111];
int d[111];
bool vi[111];
void ff(int k) {
  if (vi[k]) return;
  vi[k] = true;
  for (int i = 0; i < (int)e[k].size(); i++) {
    int v = e[k][i].first;
    int c = e[k][i].second;
    if (d[k] - c == v) {
      f[k][v] = f[v][k] = 0;
      ff(k);
    }
  }
}
void dij(int x) {
  for (int i = 0; i < n; i++) d[i] = 1 << 28;
  priority_queue<pair<int, int>, vector<pair<int, int> >,
                 greater<pair<int, int> > >
      que;
  d[x] = 0;
  que.push(make_pair(0, x));
  while (!que.empty()) {
    int c = que.top().first;
    int v = que.top().second;
    que.pop();
    if (d[v] < c) continue;
    for (int i = 0; i < (int)e[v].size(); i++) {
      int u = e[v][i].first;
      int cc = e[v][i].second;
      if (d[u] > d[v] + cc) {
        d[u] = d[v] + cc;
        que.push(make_pair(u, d[u]));
      }
    }
  }
  memset(vi, false, sizeof(vi));
  for (int i = 0; i < n; i++) {
    ff(i);
  }
}
int main(void) {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    e[a].push_back(make_pair(b, c));
    e[b].push_back(make_pair(a, c));
    f[a][b] = f[b][a] = 1;
  }
  for (int i = 0; i < n; i++) dij(i);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      ans += f[i][j];
    }
  }
  cout << ans / 2 << endl;
}
