文件目录

#include <bits/stdc++.h>
using namespace std;
int t[105][3];
int n, x, y, l, r;
int ans = 0;
void zxbl(int p)
{
    if (p == 0)
        return;
    zxbl(t[p][1]);
    ans++;
    if (t[p][0] == x)
        cout << ans;
    zxbl(t[p][2]);
}
int main()
{
    cin >> n >> x;
    for (int i = 1; i <= n; i++)
    {
        cin >> y >> l >> r;
        t[i][0] = y;
        t[i][1] = l;
        t[i][2] = r;
    }
    zxbl(1);
    return 0;
}