#include <bits/stdc++.h>
using namespace std;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
void printA(vector<T> &printArray, char between = ' ') {
  int paSize = printArray.size();
  for (int i = 0; i < paSize; i++) {
    cerr << printArray[i] << between;
  }
  if (between != '\n') {
    cerr << endl;
  }
}
using pii = pair<int, int>;
const int INF = 1e8;
int N, M;
int G[111][111];
int used[111][111];
bool visited[111];
set<pii> useEdge;
void dfs(int from, int to, int cost) {
  if (from == to && cost == G[from][to]) {
    set<int, int> tmp;
    for (int(i) = (0); (i) < (N); ++(i)) {
      for (int(j) = (i + 1); (j) < (N); ++(j)) {
        if (used[i][j]) {
          useEdge.insert(make_pair(i, j));
        }
      }
    }
    return;
  }
  visited[from] = true;
  for (int(i) = (0); (i) < (N); ++(i)) {
    if (visited[i]) continue;
    used[from][i] = used[i][from] = true;
    dfs(i, to, cost + G[from][i]);
    used[from][i] = false;
  }
  visited[from] = false;
}
int main() {
  cin >> N >> M;
  for (int(i) = (0); (i) < (N); ++(i)) {
    for (int(j) = (0); (j) < (N); ++(j)) {
      if (i == j) continue;
      G[i][j] = INF;
    }
  }
  for (int(i) = (0); (i) < (M); ++(i)) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--, c--;
    G[a][b] = G[a][b] = c;
  }
  for (int(k) = (0); (k) < (N); ++(k)) {
    for (int(i) = (0); (i) < (N); ++(i)) {
      for (int(j) = (0); (j) < (N); ++(j)) {
        G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
      }
    }
  }
  for (int(i) = (0); (i) < (N); ++(i)) {
    for (int(j) = (i + 1); (j) < (N); ++(j)) {
      fill(visited, visited + N, false);
      for (int(k) = (0); (k) < (N); ++(k))
        for (int(l) = (0); (l) < (N); ++(l)) used[k][l] = false;
      dfs(i, j, 0);
    }
  }
  cout << max(0, M - (int)useEdge.size()) << endl;
  return 0;
}
