// NOTE: it is recommended to use this even if you don't understand the following code.

#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

#define MAXM 100000
#define MAXN 100000

int M, N, ans, i;
int A[MAXN - 1], B[MAXN - 1];
int T[MAXM], X[MAXM];

int main() {
    // uncomment the two following lines if you want to read/write from files
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    assert(2 == scanf("%d%d", &N, &M));

    for (i = 0; i < N - 1; ++i)
        assert(2 == scanf("%d%d", &A[i], &B[i]));

    for (i = 0; i < M; ++i)
        assert(2 == scanf("%d%d", &X[i], &T[i]));

    ans = 0;


    // INSERT YOUR CODE HERE


    printf("%d\n", ans);

    return 0;
}
