#include<bits/stdc++.h>
using namespace std;
#define INF 1e9
const int UNVISITED = -1;
const int VISITED = 0;
vector<int> graph[105];
bool isArticulationPoint[105];
int dfs_status[105];
int dfs_parent[105];
int dfs_depth[105];
int dfs_low[105];
void dfsArticulationPoints(int u)
{
dfs_status[u] = VISITED;
dfs_low[u] = dfs_depth[u];
int childrensCount = 0;
bool articulationPoint = false;
for (auto v: graph[u])
{
if (dfs_status[v] == UNVISITED)
{
dfs_depth[v] = dfs_depth[u] + 1;
childrensCount++;
dfs_parent[v] = u;
dfsArticulationPoints(v);
if (dfs_low[v] >= dfs_depth[u])
{
articulationPoint = true;
}
else
{
dfs_low[u] = min(dfs_low[u], dfs_low[v]);
}
}
else if (dfs_parent[u] != v)
{
dfs_low[u] = min(dfs_low[u], dfs_depth[v]);
}
}
if ((dfs_parent[u] == -1 && childrensCount >= 2) || (dfs_parent[u] != -1 && articulationPoint))
{
isArticulationPoint[u] = true;
}
}
int main()
{
#ifdef VSP4
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif // VSP4
int t, i, j, n, m, u, v, ans, zeroColored, oneColored;
string str;
stringstream ss;
while (cin >> n >> ws, n)
{
for (i = 1; i <= n; i++)
{
graph[i].clear();
}
while (getline(cin, str), ss.clear(), ss.str(str), ss >> u, u)
{
while (ss >> v)
{
graph[u].push_back(v);
graph[v].push_back(u);
//cout << u << "-" << v << "\n";
}
}
memset(dfs_status, UNVISITED, sizeof(dfs_status));
memset(isArticulationPoint, false, sizeof(isArticulationPoint));
dfs_depth[1] = 0;
dfs_parent[1] = -1;
dfsArticulationPoints(1);
ans = 0; //records no of articulation points
for (i = 1; i <= n; i++)
{
if (isArticulationPoint[i])
{
ans++;
}
}
cout << ans << "\n";
}
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgojZGVmaW5lIElORiAxZTkKCmNvbnN0IGludCBVTlZJU0lURUQgPSAtMTsKY29uc3QgaW50IFZJU0lURUQgPSAwOwoKdmVjdG9yPGludD4gZ3JhcGhbMTA1XTsKYm9vbCBpc0FydGljdWxhdGlvblBvaW50WzEwNV07CmludCBkZnNfc3RhdHVzWzEwNV07CmludCBkZnNfcGFyZW50WzEwNV07CmludCBkZnNfZGVwdGhbMTA1XTsKaW50IGRmc19sb3dbMTA1XTsKCnZvaWQgZGZzQXJ0aWN1bGF0aW9uUG9pbnRzKGludCB1KQp7CiAgICBkZnNfc3RhdHVzW3VdID0gVklTSVRFRDsKCiAgICBkZnNfbG93W3VdID0gZGZzX2RlcHRoW3VdOwoKICAgIGludCBjaGlsZHJlbnNDb3VudCA9IDA7CiAgICBib29sIGFydGljdWxhdGlvblBvaW50ID0gZmFsc2U7CgogICAgZm9yIChhdXRvIHY6IGdyYXBoW3VdKQogICAgewogICAgICAgIGlmIChkZnNfc3RhdHVzW3ZdID09IFVOVklTSVRFRCkKICAgICAgICB7CiAgICAgICAgICAgIGRmc19kZXB0aFt2XSA9IGRmc19kZXB0aFt1XSArIDE7CiAgICAgICAgICAgIGNoaWxkcmVuc0NvdW50Kys7CgogICAgICAgICAgICBkZnNfcGFyZW50W3ZdID0gdTsKICAgICAgICAgICAgZGZzQXJ0aWN1bGF0aW9uUG9pbnRzKHYpOwoKICAgICAgICAgICAgaWYgKGRmc19sb3dbdl0gPj0gZGZzX2RlcHRoW3VdKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBhcnRpY3VsYXRpb25Qb2ludCA9IHRydWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZWxzZQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBkZnNfbG93W3VdID0gbWluKGRmc19sb3dbdV0sIGRmc19sb3dbdl0pOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGVsc2UgaWYgKGRmc19wYXJlbnRbdV0gIT0gdikKICAgICAgICB7CiAgICAgICAgICAgIGRmc19sb3dbdV0gPSBtaW4oZGZzX2xvd1t1XSwgZGZzX2RlcHRoW3ZdKTsKICAgICAgICB9CiAgICB9CgogICAgaWYgKChkZnNfcGFyZW50W3VdID09IC0xICYmIGNoaWxkcmVuc0NvdW50ID49IDIpIHx8IChkZnNfcGFyZW50W3VdICE9IC0xICYmIGFydGljdWxhdGlvblBvaW50KSkKICAgIHsKICAgICAgICBpc0FydGljdWxhdGlvblBvaW50W3VdID0gdHJ1ZTsKICAgIH0KfQoKaW50IG1haW4oKQp7CiAgICAjaWZkZWYgVlNQNAogICAgZnJlb3BlbigiaW5wdXQudHh0IiwgInIiLCBzdGRpbik7CiAgICBmcmVvcGVuKCJvdXRwdXQudHh0IiwgInciLCBzdGRvdXQpOwogICAgI2VuZGlmIC8vIFZTUDQKCiAgICBpbnQgdCwgaSwgaiwgbiwgbSwgdSwgdiwgYW5zLCB6ZXJvQ29sb3JlZCwgb25lQ29sb3JlZDsKICAgIHN0cmluZyBzdHI7CiAgICBzdHJpbmdzdHJlYW0gc3M7CgogICAgd2hpbGUgKGNpbiA+PiBuID4+IHdzLCBuKQogICAgewogICAgICAgIGZvciAoaSA9IDE7IGkgPD0gbjsgaSsrKQogICAgICAgIHsKICAgICAgICAgICAgZ3JhcGhbaV0uY2xlYXIoKTsKICAgICAgICB9CgogICAgICAgIHdoaWxlIChnZXRsaW5lKGNpbiwgc3RyKSwgc3MuY2xlYXIoKSwgc3Muc3RyKHN0ciksIHNzID4+IHUsIHUpCiAgICAgICAgewogICAgICAgICAgICB3aGlsZSAoc3MgPj4gdikKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgZ3JhcGhbdV0ucHVzaF9iYWNrKHYpOwogICAgICAgICAgICAgICAgZ3JhcGhbdl0ucHVzaF9iYWNrKHUpOwogICAgICAgICAgICAgICAgLy9jb3V0IDw8IHUgPDwgIi0iIDw8IHYgPDwgIlxuIjsKICAgICAgICAgICAgfQogICAgICAgIH0KCiAgICAgICAgbWVtc2V0KGRmc19zdGF0dXMsIFVOVklTSVRFRCwgc2l6ZW9mKGRmc19zdGF0dXMpKTsKICAgICAgICBtZW1zZXQoaXNBcnRpY3VsYXRpb25Qb2ludCwgZmFsc2UsIHNpemVvZihpc0FydGljdWxhdGlvblBvaW50KSk7CgogICAgICAgIGRmc19kZXB0aFsxXSA9IDA7CiAgICAgICAgZGZzX3BhcmVudFsxXSA9IC0xOwogICAgICAgIGRmc0FydGljdWxhdGlvblBvaW50cygxKTsKCiAgICAgICAgYW5zID0gMDsgLy9yZWNvcmRzIG5vIG9mIGFydGljdWxhdGlvbiBwb2ludHMKCiAgICAgICAgZm9yIChpID0gMTsgaSA8PSBuOyBpKyspCiAgICAgICAgewogICAgICAgICAgICBpZiAoaXNBcnRpY3VsYXRpb25Qb2ludFtpXSkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgYW5zKys7CiAgICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIGNvdXQgPDwgYW5zIDw8ICJcbiI7CiAgICB9CgogICAgcmV0dXJuIDA7Cn0K