#include <bits/stdc++.h>
using namespace std;
const int MN = 1e5 + 5;
int n, m, k, i, x, y, w, dist[MN], ans;
vector<tuple<long long, int> > adj[MN];
priority_queue<tuple<long long, int, int> > q;
int main() {
  for (scanf("%d%d%d", &n, &m, &k), i = 0; i < m; i++) {
    scanf("%d%d%d", &x, &y, &w);
    adj[x].push_back(make_tuple(y, w));
    adj[y].push_back(make_tuple(x, w));
  }
  for (i = 0; i < k; i++) {
    scanf("%d%d", &x, &y);
    q.push(make_tuple(-y, x, 0));
  }
  q.push(make_tuple(0, 1, 1));
  while (!q.empty()) {
    auto t = q.top();
    q.pop();
    x = get<1>(t), y = -get<0>(t), w = get<2>(t);
    if (dist[x]) continue;
    if (w == 0) ans++;
    dist[x] = y;
    for (auto t2 : adj[x]) {
      if (!dist[get<0>(t2)] && get<0>(t2))
        q.push(make_tuple(-1LL * (y + get<1>(t2)), get<0>(t2), 1));
    }
  }
  printf("%d\n", k - ans);
  return 0;
}
