#include<bits/stdc++.h>
using namespace std;
int L[1000002];
int M[1000002];
int main()
{

int n,x,y,j,cnt;
cin>>n;
for(int i=1; i<=n; i++)scanf("%d",&L[i]);
if(n==1)
    cout<<1<<endl;
else{
        cnt=0;
for(int i=1;i<=n;i++)M[i]=1;

       int i=n;
        while(i>=2)
        {

            int p=0;
            j=i-1;
            while(p<L[i])
            {
                x=i-L[i];
            if(x<=j)
                M[j]=-1;

                p++;
                j--;
            }
            i--;

        }
        for(int i=1; i<=n; i++)
            if(M[i]==1)cnt++;
        cout<<cnt<<endl;
}

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int L[1000002];
int M[1000002];
int main()
{

int n,x,y,j,cnt;
cin>>n;
for(int i=1; i<=n; i++)scanf("%d",&L[i]);
if(n==1)
    cout<<1<<endl;
else{
        cnt=0;
for(int i=1;i<=n;i++)M[i]=1;

       int i=n;
        while(i>=2)
        {

            int p=0;
            j=i-1;
            while(p<L[i]&& j>=1)
            {
                x=i-L[i];
            if(x<=j)
                M[j]=-1;

                p++;
                j--;
                if(j==0)break;
            }
            if(j==0)break;
            i--;

        }
        for(int i=1; i<=n; i++)
            if(M[i]==1)cnt++;
        cout<<cnt<<endl;
}

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int L[1000002];
int M[1000002];
int main()
{

int n,x,y,j,cnt;
    while(cin>>n)
    {
        cnt=0;
         for(int i=1;i<=n;i++)M[i]=1;

        for(int i=1; i<=n; i++)cin>>L[i];
       int i=n;
        while(i>=2)
        {
            //if(M[i]==-1)
          //  {
              //  i--;
              //  continue;
            //}
            int p=0;
            j=i-1;
            while(p<=L[i])
            {
                x=i-L[i];
            if(x<=j)
                M[j]=-1;
                p++;
                j--;
            }
            i--;

        }
        for(int i=1; i<=n; i++)
            //cout<<M[i]<<" ";
            if(M[i]==1)cnt++;
        cout<<cnt<<endl;

    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int L[1000002];
int M[1000002];
int main()
{

int n,x,y,j,cnt;
cin>>n;
for(int i=1; i<=n; i++)scanf("%d",&L[i]);
if(n==1)
    cout<<1<<endl;
else{
        cnt=0;
for(int i=1;i<=n;i++)M[i]=1;

       int i=n;
        while(i>=2)
        {

            int p=0;
            j=i-1;
            while(p<L[i]&& j>1)
            {
                x=i-L[i];
            if(x<=j)
                M[j]=-1;

                p++;
                j--;
            }
            i--;

        }
        for(int i=1; i<=n; i++)
            if(M[i]==1)cnt++;
        cout<<cnt<<endl;
}

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn=1000010;
typedef long long ll;
int a[maxn];
int ans;
int f(int i , int maxx){
	int minn = max(i-a[i] , maxx);
	ans -= i - 1 - minn + 1;
	return i;
}
int main()
{
    int n;
    while (~scanf("%d", &n)){

		int maxx = 0;
		ans = n;
    	for (int i=1; i<=n; i++){
    		scanf ("%d", &a[i]);
    		int t = i - a[i];
    		if (i!=1 && t<=i-1){
    			maxx = f(i , maxx);
			}
		}
    	printf("%d\n", ans);
	}
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int a[1000010] , b[1000010];
int main(){
    int n;
    while (~scanf("%d", &n)){
        memset(b, 0, sizeof b);
        for (int i=1; i<=n; i++)  {
            scanf("%d", &a[i]);
            int l = max(0, i-a[i]) , r = i - 1;
            b[l]++ , b[r+1]--;
        }

        int ans = 0;
        for (int i=1; i<=n; i++) {
            b[i] += b[i-1];
            if (b[i] == 0)  ans ++;
        }
        printf("%d\n", ans);
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn=1000010;
typedef long long ll;
int a[maxn];
int f(int i , int maxx){
	int minn = max(i-a[i] , maxx);
	int ans = i - 1 - minn + 1;
	return i;
}
int main()
{
    int n;
    while (~scanf("%d", &n)){

		int maxx = 0 , ans = n;
    	for (int i=1; i<=n; i++){
    		scanf ("%d", &a[i]);
    		int t = i - a[i];
    		if (i!=1 && t<=i-1){
    			int xx = f(i,maxx);
    			int minn = max(i-a[i] , maxx);
				ans -= i - 1 - minn + 1;
				maxx = i;
			}
		}
    	printf("%d\n", ans);
	}
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn=1000010;
typedef long long ll;
ll a[maxn];
ll ans = 0;
ll f(int i , ll maxx){
	ll minn = max(i-a[i] , maxx);
	ans -= i - 1 - minn + 1;
	return i;
}
int main()
{
    int n;
    while (~scanf("%d", &n)){

		ll  maxx = 0;
		ans = n;
    	for (int i=1; i<=n; i++){
    		scanf ("%I64d", &a[i]);
    		ll t = i - a[i];
    		if (i!=1 && t<=i-1){
    			maxx = f(i , maxx);
			}
		}
    	printf("%I64d\n", ans);
	}
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn=1000010;
typedef long long ll;
int a[maxn];
int f(int i , int maxx){
	int minn = max(i-a[i] , maxx);
	int ans = i - 1 - minn + 1;
	return i;
}
int main()
{
    int n;
    while (~scanf("%d", &n)){

		int maxx = 1 , ans = n;
    	for (int i=1; i<=n; i++){
    		scanf ("%d", &a[i]);
    		int t = i - a[i];
    		if (i!=1 && t<=i-1){
    			int xx = f(i,maxx);
    			int minn = max(i-a[i] , maxx);
				ans -= i - 1 - minn + 1;
				maxx = i;
			}
		}
    	printf("%d\n", ans);
	}
    return 0;
}


#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int n,dp[1000001],l[1000001],s[1000001],e[1000001];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>l[i];
		s[i]=i-l[i];
		e[i]=i-1;
	}
	dp[1]=1;
	for(int i=2;i<=n;i++){
		if(s[i]>e[i]) dp[i]=dp[i-1]+1;
		else {
			if(s[i]<=e[i-1]) if(s[i]>=1) dp[i]=min(dp[i-1],dp[s[i]]);
			                 else dp[i]=1;
			else dp[i]=dp[i-1];
		}
	}
	printf("%d",dp[n]);

	return 0;
}


#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int n,dp[1000001],l[1000001],s[1000001],e[1000001];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>l[i];
		s[i]=i-l[i];
	}
	dp[1]=1;
	for(int i=2;i<=n;i++){
		if(l[i]==0) dp[i]=dp[i-1]+1;
		else {
			if(s[i]<=i-2) if(s[i]>=1) dp[i]=min(dp[i-1],dp[s[i]]);
			                 else dp[i]=1;
			else dp[i]=dp[i-1];
		}
	}
	printf("%d",dp[n]);
	return 0;
}


#include<cstdio>
#include<stack>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
stack<int>a;
int n,l;
int main(){
	cin>>n;
	a.push(1);
	scanf("%d",&l);
	for(int i=2;i<=n;i++){
		scanf("%d",&l);
		while(a.size()!=0&&a.top()>=i-l){
			a.pop();
		}
		a.push(i);
	}
	printf("%d",a.size());

	return 0;
}


#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int n,dp[1000001],l[1000001];
int main(){
	cin>>n;dp[1]=1;
	for(int i=1;i<=n;i++){
		scanf("%d",&l[i]);
		if(l[i]==0) dp[i]=dp[i-1]+1;
		else if(l[i]>=2) if(i-l[i]>=1) dp[i]=min(dp[i-1],dp[i-l[i]]);
			                else dp[i]=1;
		else if(l[i]==1) dp[i]=dp[i-1];
		}
	printf("%d",dp[n]);
	return 0;
}


#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int n,dp[1000001],l[1000001];
int main(){
	cin>>n;dp[1]=1;
	for(int i=1;i<=n;i++){
		cin>>l[i];
		if(l[i]==0) dp[i]=dp[i-1]+1;
		else if(l[i]>=2) if(i-l[i]>=1) dp[i]=min(dp[i-1],dp[i-l[i]]);
			                else dp[i]=1;
		else if(l[i]==1) dp[i]=dp[i-1];
		}
	printf("%d",dp[n]);
	return 0;
}


#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int n,dp[1000001],l[1000001];
int main(){
	cin>>n;dp[1]=1;
	for(int i=1;i<=n;i++){
		scanf("%d",&l[i]);
		if(l[i]==0) dp[i]=dp[i-1]+1;
		else if(l[i]>=2) if(i-l[i]>=1) dp[i]=dp[i-l[i]];
			                else dp[i]=1;
		else if(l[i]==1) dp[i]=dp[i-1];
		}
	printf("%d",dp[n]);
	return 0;
}


#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int n,dp[1000001],l[1000001],s[1000001],e[1000001];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>l[i];
		s[i]=i-l[i];
		e[i]=i-1;
	}
	dp[1]=1;
	for(int i=2;i<=n;i++){
		if(s[i]>e[i]){ dp[i]=dp[i-1]+1;
		}
		else {
				if(s[i]>=1) dp[i]=dp[s[i]];
				else dp[i]=1;
		}
	}
	printf("%d",dp[n]);

	return 0;
}


#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int n,dp[1000001],l[1000001];
int main(){
	cin>>n;dp[1]=1;
	for(int i=1;i<=n;i++){
		cin>>l[i];
		if(l[i]==0) dp[i]=dp[i-1]+1;
		else {
			if(l[i]>=2) if(i-l[i]>=1) dp[i]=min(dp[i-1],dp[i-l[i]]);
			                 else dp[i]=1;
			else dp[i]=dp[i-1];
		}
	}
	printf("%d",dp[n]);
	return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
int b[2234567];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int i,n,l,a=0,c=0;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>l;
        if(l>i)l=i;
        b[i-l]++;
    }
    for(i=0;i<n;i++)
    {
        c+=b[i];
        c--;
        if(c==0)a++;
    }
    cout<<a<<'\n';
}


#include<iostream>
#include<algorithm>
using namespace std;
int b[123567];
int main()
{
    int i,n,l,a=0,c=0;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>l;
        b[max(i-l,0)]++;
    }
    for(i=0;i<n;i++)
    {
        c+=b[i];
        c--;
        if(c==0)a++;
    }
    cout<<a<<endl;
}


#include<iostream>
#include<algorithm>
using namespace std;
int b[123567];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int i,n,l,a=0,c=0;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>l;
        if(l>i)l=i;
        b[i-l]++;
    }
    for(i=0;i<n;i++)
    {
        c+=b[i];
        c--;
        if(c==0)a++;
    }
    cout<<a<<'\n';
}


#include<iostream>
#include<algorithm>
using namespace std;
int b[123567];
int main()
{
    int i,n,l,a=0,c=0;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>l;
        b[max(i-l,0)]++;
    }
    for(i=0;i<n;i++)
    {
        c+=b[i];
        c--;
        if(c==0)a++;
    }
    cout<<a<<endl;
}
//this has to work


#include<iostream>
#include<algorithm>
using namespace std;
int b[123567];
int main()
{
    int i,n,l,a=0,c=0;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>l;
        if(l>i)l=i;
        b[i-l]++;
    }
    for(i=0;i<n;i++)
    {
        c+=b[i];
        c--;
        if(c==0)a++;
    }
    cout<<a<<endl;
}
//this has to work


#include<iostream>
#include<algorithm>
using namespace std;
int b[123567];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int i,n,l,a=0,c=0;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>l;
        if(l>i)l=i;
        b[i-l]++;
    }
    for(i=0;i<n;i++)
    {
        c+=b[i];
        c--;
        if(c==0)a++;
    }
    cout<<a<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll n,i,j,save,a=0;
    cin>>n;
    ll l[n];
    for(i=0; i<n; i++)
        cin>>l[i];
    save=n-1-l[n-1];
    for(i=n-2;i>=0;i--)
    {
        if(i>=save)
            a++;
        save=min(save,i-l[i]);
    }
    cout<<n-a<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll n,i,a,j;
    cin>>n;
    ll l[n];
    for(i=0; i<n; i++)
    {
        cin>>l[i];
        l[i]=i-l[i];
    }
    j=n-2;
    i=n-1;
    while(j>=0&&i>=0)
    {
        while(j>=l[i]&&j>=0)
        {
            n--;
            j--;
        }
        i--;
        if(j==i)
            j--;
    }
    cout<<n<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
bool visited[1000007];
int main()
{
    ll sum=0,n,i,a;
    vector<pair<int,int> >v;
    vector<pair<int,int> >::iterator it,jt;
    cin>>n;
    if(n==1)
    {
        cout<<"1"<<endl;
        return 0;
    }
    for(i=0; i<n; i++)
    {
        cin>>a;
        v.push_back(make_pair(i,i-a));
    }
    it=v.end();
    it--;
    while(it!=v.begin())
    {
        jt=v.begin();
        while(1)
        {
            if(jt->first==it->first)
                break;
            if(jt->first>=it->second && visited[jt->first]==0)
            {
                n--;
                visited[jt->first]=1;
            }
            jt++;
        }
        it--;
    }
    cout<<n<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll n,i,a,j,save=0;
    cin>>n;
    ll l[n];
    for(i=0; i<n; i++)
    {
        cin>>l[i];
        l[i]=i-l[i];
        save=min(save,l[i]);
    }
    j=n-2;
    i=n-1;
    if(save<=0)
    {
        cout<<"0"<<endl;
        return 0;
    }
    while(j>=0&&i>=0)
    {
        while(j>=l[i]&&j>=0)
        {
            n--;
            j--;
        }
        i--;
        if(j==i)
            j--;
    }
    cout<<n<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define li long int
li l[1000007];
int main()
{
    li n,i,j,save,a=1;
    cin>>n;
    for(i=1; i<=n; i++)
        cin>>l[i];
    save=n-l[n];
    for(i=n-1;i>=1;i--)
    {
        if(save<=0)
            break;
        if(i<save)
            a++;
        save=min(save,i-l[i]);
    }
    cout<<a<<endl;
    return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;
long l[1000007],n,i,j,save,a=1;
int main()
{
    scanf("%ld",&n);
    for(i=1; i<=n; i++)
        scanf("%ld",&l[i]);
    save=n-l[n];
    for(i=n-1;i>=1;i--)
    {
        if(save<=0)
            break;
        if(i<save)
            a++;
        save=min(save,i-l[i]);
    }
    printf("%ld\n",a);
    return 0;
}


#include <bits/stdc++.h>
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <cstring>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <stdlib.h>
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <vector>
#define mem(a,b) memset(a,b,sizeof(a))
#define findx(x) lower_bound(b+1,b+1+bn,x)-b
#define FIN      freopen("input.txt","r",stdin)
#define FOUT     freopen("output.txt","w",stdout)
#define S1(n)    scanf("%d",&n)
#define SL1(n)   scanf("%I64d",&n)
#define S2(n,m)  scanf("%d%d",&n,&m)
#define SL2(n,m)  scanf("%I64d%I64d",&n,&m)
#define Pr(n)     printf("%d\n",n)
#define lson rt << 1, l, mid
#define rson rt << 1|1, mid + 1, r

using namespace std;
typedef long long ll;
const double PI=acos(-1);
const int INF=0x3f3f3f3f;
const double esp=1e-6;
const int maxn=1e6+5;
const int MAXN=50005;
const int MAX=1<<22;
const int MOD=1e9+7;
const int mod=1e9+7;
int dir[5][2]={0,1,0,-1,1,0,-1,0};

ll inv[maxn*2];
inline void ex_gcd(ll a,ll b,ll &d,ll &x,ll &y){if(!b){ x=1; y=0; d=a; }else{ ex_gcd(b,a%b,d,y,x); y-=x*(a/b);};}
inline ll gcd(ll a,ll b){ return b?gcd(b,a%b):a;}
inline ll exgcd(ll a,ll b,ll &x,ll &y){if(!b){x=1;y=0;return a;}ll ans=exgcd(b,a%b,x,y);ll temp=x;x=y;y=temp-a/b*y;return ans;}
inline ll lcm(ll a,ll b){ return b/gcd(a,b)*a;}
inline ll qpow(ll x,ll n){ll res=1;for(;n;n>>=1){if(n&1)res=(res*x)%MOD;x=(x*x)%MOD;}return res;}
inline ll inv_exgcd(ll a,ll n){ll d,x,y;ex_gcd(a,n,d,x,y);return d==1?(x+n)%n:-1;}
inline ll inv1(ll b){return b==1?1:(MOD-MOD/b)*inv1(MOD%b)%MOD;}
inline ll inv2(ll b){return qpow(b,MOD-2);}
int b[maxn];
int vis[maxn];

struct math_tree{
	int n;
	int a[MAX],Max[MAX],Min[MAX];
	int tree[MAX];
	void init(int N)
	{
		n=N;
		for(int i=0;i<=N;i++)
			Max[i]=-(Min[i]=INF);
	}
	void update(int k,int num)//单点更新
	{
		a[k]=num;
		while(k<=n)
		{
			tree[k]+=num;
			Min[k]=Max[k]=a[k];
			int lk=k&(-k);
			for(int i=1;i<lk;i<<=1)
			{
				Max[k]=max(Max[k],Max[k-i]);
				Min[k]=min(Min[k],Min[k-i]);
			}
			k+=k&(-k);// lowbit(k)= k&(-k);
		}
	}
	int Sum(int k)
	{
		int sum=0;
		while(k)
		{
			sum+=tree[k];
			k-=k&-k;
		}
		return sum;
	}
	int Get_Sum(int x,int y)
	{
		return Sum(y)-Sum(x-1);
	}
	int Qmax(int x,int y)//[x,y]区间最大值
    {
        int ans=-INF;
        while(y>=x)
        {
            ans=max(a[y], ans);
            y--;
            for(;y-(y&-y)>=x;y-=(y&-y))
                ans=max(Max[y],ans);
        }
        return ans;
    }
	int Qmin(int x,int y)//[x,y] 区间最小值
	{
		int ans=INF;
		while(y>=x)
		{
			ans=min(a[y],ans);
			y--;
			for(;y-(y&-y)>=x;y-=(y&-y))
				ans=min(ans,Min[y]);
		}
		return ans;
	}
}A;

int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        int x;
        A.init(n);
        for(int i=1;i<=n;i++)
        {
            S1(x);
            if(i-x<0)
                b[i]=1;
            else
                b[i]= i-x;
            A.update(i,b[i]);
        }
        int ans=1;

        for(int i=n-1;i>=1;i--)
        {
           // printf("%d\n",A.Qmin(i,n));
            if(i<A.Qmin(i+1,n))
            {
                ans++;
             //   printf("**\n");
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}


#include <bits/stdc++.h>
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <cstring>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <stdlib.h>
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <vector>
#define mem(a,b) memset(a,b,sizeof(a))
#define findx(x) lower_bound(b+1,b+1+bn,x)-b
#define FIN      freopen("input.txt","r",stdin)
#define FOUT     freopen("output.txt","w",stdout)
#define S1(n)    scanf("%d",&n)
#define SL1(n)   scanf("%I64d",&n)
#define S2(n,m)  scanf("%d%d",&n,&m)
#define SL2(n,m)  scanf("%I64d%I64d",&n,&m)
#define Pr(n)     printf("%d\n",n)
#define lson rt << 1, l, mid
#define rson rt << 1|1, mid + 1, r

using namespace std;
typedef long long ll;
const double PI=acos(-1);
const int INF=0x3f3f3f3f;
const double esp=1e-6;
const int maxn=1e6+5;
const int MAXN=50005;
const int MOD=1e9+7;
const int mod=1e9+7;
int dir[5][2]={0,1,0,-1,1,0,-1,0};

ll inv[maxn*2];
inline void ex_gcd(ll a,ll b,ll &d,ll &x,ll &y){if(!b){ x=1; y=0; d=a; }else{ ex_gcd(b,a%b,d,y,x); y-=x*(a/b);};}
inline ll gcd(ll a,ll b){ return b?gcd(b,a%b):a;}
inline ll exgcd(ll a,ll b,ll &x,ll &y){if(!b){x=1;y=0;return a;}ll ans=exgcd(b,a%b,x,y);ll temp=x;x=y;y=temp-a/b*y;return ans;}
inline ll lcm(ll a,ll b){ return b/gcd(a,b)*a;}
inline ll qpow(ll x,ll n){ll res=1;for(;n;n>>=1){if(n&1)res=(res*x)%MOD;x=(x*x)%MOD;}return res;}
inline ll inv_exgcd(ll a,ll n){ll d,x,y;ex_gcd(a,n,d,x,y);return d==1?(x+n)%n:-1;}
inline ll inv1(ll b){return b==1?1:(MOD-MOD/b)*inv1(MOD%b)%MOD;}
inline ll inv2(ll b){return qpow(b,MOD-2);}
int a[maxn];
int vis[maxn];

int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        mem(a,0);
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&a[i]);
        }
        int ans=0;
        mem(vis,0);
        int flag=0;
        int lo=0;
        for(int i=n;i>=1;i--)
        {
            int j=i-a[i];
            if(j<=0)
            {
                lo=i;
                flag=1;
                break;
            }
            else
            {
                for(int k=j;k<i;k++)
                {
                    if(!vis[k])
                    {
                        vis[k]=1;
                    }
                }
            }
        }
        if(!flag)
        {
            for(int i=1;i<=n;i++)
            {
                if(!vis[i])
                    ans++;
            }
        }
        else
        {
            for(int i=lo;i<=n;i++)
            {
                if(!vis[i])
                    ans++;
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}


#include <bits/stdc++.h>
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <cstring>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <stdlib.h>
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <vector>
#define mem(a,b) memset(a,b,sizeof(a))
#define findx(x) lower_bound(b+1,b+1+bn,x)-b
#define FIN      freopen("input.txt","r",stdin)
#define FOUT     freopen("output.txt","w",stdout)
#define S1(n)    scanf("%d",&n)
#define SL1(n)   scanf("%I64d",&n)
#define S2(n,m)  scanf("%d%d",&n,&m)
#define SL2(n,m)  scanf("%I64d%I64d",&n,&m)
#define Pr(n)     printf("%d\n",n)
#define lson rt << 1, l, mid
#define rson rt << 1|1, mid + 1, r

using namespace std;
typedef long long ll;
const double PI=acos(-1);
const int INF=0x3f3f3f3f;
const double esp=1e-6;
const int maxn=1e6+5;
const int MAXN=50005;
const int MOD=1e9+7;
const int mod=1e9+7;
int dir[5][2]={0,1,0,-1,1,0,-1,0};

ll inv[maxn*2];
inline void ex_gcd(ll a,ll b,ll &d,ll &x,ll &y){if(!b){ x=1; y=0; d=a; }else{ ex_gcd(b,a%b,d,y,x); y-=x*(a/b);};}
inline ll gcd(ll a,ll b){ return b?gcd(b,a%b):a;}
inline ll exgcd(ll a,ll b,ll &x,ll &y){if(!b){x=1;y=0;return a;}ll ans=exgcd(b,a%b,x,y);ll temp=x;x=y;y=temp-a/b*y;return ans;}
inline ll lcm(ll a,ll b){ return b/gcd(a,b)*a;}
inline ll qpow(ll x,ll n){ll res=1;for(;n;n>>=1){if(n&1)res=(res*x)%MOD;x=(x*x)%MOD;}return res;}
inline ll inv_exgcd(ll a,ll n){ll d,x,y;ex_gcd(a,n,d,x,y);return d==1?(x+n)%n:-1;}
inline ll inv1(ll b){return b==1?1:(MOD-MOD/b)*inv1(MOD%b)%MOD;}
inline ll inv2(ll b){return qpow(b,MOD-2);}
int a[maxn];
int vis[maxn];
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        mem(a,0);
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&a[i]);
        }
        int ans=0;
        mem(vis,0);
        int flag=0;
        int lo=0;
        for(int i=n;i>=1;i--)
        {
            int j=i-a[i];
            if(j<=0)
            {
                lo=i;
                flag=1;
                break;
            }
            else
            {
                for(int k=j;k<i;k++)
                {
                    if(!vis[k])
                    {
                        vis[k]=1;
                    }
                }
            }
        }
        if(!flag)
        {
            for(int i=1;i<=n;i++)
            {
                if(!vis[i])
                    ans++;
            }
        }
        else
        {
            for(int i=lo;i<=n;i++)
            {
                if(!vis[i])
                    ans++;
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}


#include <bits/stdc++.h>
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <cstring>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <stdlib.h>
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <vector>
#define mem(a,b) memset(a,b,sizeof(a))
#define findx(x) lower_bound(b+1,b+1+bn,x)-b
#define FIN      freopen("input.txt","r",stdin)
#define FOUT     freopen("output.txt","w",stdout)
#define S1(n)    scanf("%d",&n)
#define SL1(n)   scanf("%I64d",&n)
#define S2(n,m)  scanf("%d%d",&n,&m)
#define SL2(n,m)  scanf("%I64d%I64d",&n,&m)
#define Pr(n)     printf("%d\n",n)
#define lson rt << 1, l, mid
#define rson rt << 1|1, mid + 1, r

using namespace std;
typedef long long ll;
const double PI=acos(-1);
const int INF=0x3f3f3f3f;
const double esp=1e-6;
const int maxn=1e6+5;
const int MAXN=50005;
const int MAX=100005;
const int MOD=1e9+7;
const int mod=1e9+7;
int dir[5][2]={0,1,0,-1,1,0,-1,0};

ll inv[maxn*2];
inline void ex_gcd(ll a,ll b,ll &d,ll &x,ll &y){if(!b){ x=1; y=0; d=a; }else{ ex_gcd(b,a%b,d,y,x); y-=x*(a/b);};}
inline ll gcd(ll a,ll b){ return b?gcd(b,a%b):a;}
inline ll exgcd(ll a,ll b,ll &x,ll &y){if(!b){x=1;y=0;return a;}ll ans=exgcd(b,a%b,x,y);ll temp=x;x=y;y=temp-a/b*y;return ans;}
inline ll lcm(ll a,ll b){ return b/gcd(a,b)*a;}
inline ll qpow(ll x,ll n){ll res=1;for(;n;n>>=1){if(n&1)res=(res*x)%MOD;x=(x*x)%MOD;}return res;}
inline ll inv_exgcd(ll a,ll n){ll d,x,y;ex_gcd(a,n,d,x,y);return d==1?(x+n)%n:-1;}
inline ll inv1(ll b){return b==1?1:(MOD-MOD/b)*inv1(MOD%b)%MOD;}
inline ll inv2(ll b){return qpow(b,MOD-2);}
int b[maxn];
int vis[maxn];

struct math_tree{
	int n;
	int a[MAX],Max[MAX],Min[MAX];
	int tree[MAX];
	void init(int N)
	{
		n=N;
		for(int i=0;i<=N;i++)
			Max[i]=-(Min[i]=INF);
	}
	void update(int k,int num)//�������
	{
		a[k]=num;
		while(k<=n)
		{
			tree[k]+=num;
			Min[k]=Max[k]=a[k];
			int lk=k&(-k);
			for(int i=1;i<lk;i<<=1)
			{
				Max[k]=max(Max[k],Max[k-i]);
				Min[k]=min(Min[k],Min[k-i]);
			}
			k+=k&(-k);// lowbit(k)= k&(-k);
		}
	}
	int Sum(int k)
	{
		int sum=0;
		while(k)
		{
			sum+=tree[k];
			k-=k&-k;
		}
		return sum;
	}
	int Get_Sum(int x,int y)
	{
		return Sum(y)-Sum(x-1);
	}
	int Qmax(int x,int y)//[x,y]�������ֵ
    {
        int ans=-INF;
        while(y>=x)
        {
            ans=max(a[y], ans);
            y--;
            for(;y-(y&-y)>=x;y-=(y&-y))
                ans=max(Max[y],ans);
        }
        return ans;
    }
	int Qmin(int x,int y)//[x,y] ������Сֵ
	{
		int ans=INF;
		while(y>=x)
		{
			ans=min(a[y],ans);
			y--;
			for(;y-(y&-y)>=x;y-=(y&-y))
				ans=min(ans,Min[y]);
		}
		return ans;
	}
}A;

int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        int x;
        A.init(n);
        for(int i=1;i<=n;i++)
        {
            S1(x);
            if(i-x<0)
                b[i]=1;
            else
                b[i]= i-x;
            A.update(i,b[i]);
        }
        int ans=1;

        for(int i=n-1;i>=1;i--)
        {
            printf("%d\n",A.Qmin(i,n));
            if(i<A.Qmin(i+1,n))
            {
                ans++;
                printf("**\n");
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}


#include <bits/stdc++.h>
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <cstring>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <stdlib.h>
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <vector>
#define mem(a,b) memset(a,b,sizeof(a))
#define findx(x) lower_bound(b+1,b+1+bn,x)-b
#define FIN      freopen("input.txt","r",stdin)
#define FOUT     freopen("output.txt","w",stdout)
#define S1(n)    scanf("%d",&n)
#define SL1(n)   scanf("%I64d",&n)
#define S2(n,m)  scanf("%d%d",&n,&m)
#define SL2(n,m)  scanf("%I64d%I64d",&n,&m)
#define Pr(n)     printf("%d\n",n)
#define lson rt << 1, l, mid
#define rson rt << 1|1, mid + 1, r

using namespace std;
typedef long long ll;
const double PI=acos(-1);
const int INF=0x3f3f3f3f;
const double esp=1e-6;
const int maxn=1e6+5;
const int MAXN=50005;
const int MAX=100005;
const int MOD=1e9+7;
const int mod=1e9+7;
int dir[5][2]={0,1,0,-1,1,0,-1,0};

ll inv[maxn*2];
inline void ex_gcd(ll a,ll b,ll &d,ll &x,ll &y){if(!b){ x=1; y=0; d=a; }else{ ex_gcd(b,a%b,d,y,x); y-=x*(a/b);};}
inline ll gcd(ll a,ll b){ return b?gcd(b,a%b):a;}
inline ll exgcd(ll a,ll b,ll &x,ll &y){if(!b){x=1;y=0;return a;}ll ans=exgcd(b,a%b,x,y);ll temp=x;x=y;y=temp-a/b*y;return ans;}
inline ll lcm(ll a,ll b){ return b/gcd(a,b)*a;}
inline ll qpow(ll x,ll n){ll res=1;for(;n;n>>=1){if(n&1)res=(res*x)%MOD;x=(x*x)%MOD;}return res;}
inline ll inv_exgcd(ll a,ll n){ll d,x,y;ex_gcd(a,n,d,x,y);return d==1?(x+n)%n:-1;}
inline ll inv1(ll b){return b==1?1:(MOD-MOD/b)*inv1(MOD%b)%MOD;}
inline ll inv2(ll b){return qpow(b,MOD-2);}
int b[maxn];
int vis[maxn];

struct math_tree{
	int n;
	int a[MAX],Max[MAX],Min[MAX];
	int tree[MAX];
	void init(int N)
	{
		n=N;
		for(int i=0;i<=N;i++)
			Max[i]=-(Min[i]=INF);
	}
	void update(int k,int num)//单点更新
	{
		a[k]=num;
		while(k<=n)
		{
			tree[k]+=num;
			Min[k]=Max[k]=a[k];
			int lk=k&(-k);
			for(int i=1;i<lk;i<<=1)
			{
				Max[k]=max(Max[k],Max[k-i]);
				Min[k]=min(Min[k],Min[k-i]);
			}
			k+=k&(-k);// lowbit(k)= k&(-k);
		}
	}
	int Sum(int k)
	{
		int sum=0;
		while(k)
		{
			sum+=tree[k];
			k-=k&-k;
		}
		return sum;
	}
	int Get_Sum(int x,int y)
	{
		return Sum(y)-Sum(x-1);
	}
	int Qmax(int x,int y)//[x,y]区间最大值
    {
        int ans=-INF;
        while(y>=x)
        {
            ans=max(a[y], ans);
            y--;
            for(;y-(y&-y)>=x;y-=(y&-y))
                ans=max(Max[y],ans);
        }
        return ans;
    }
	int Qmin(int x,int y)//[x,y] 区间最小值
	{
		int ans=INF;
		while(y>=x)
		{
			ans=min(a[y],ans);
			y--;
			for(;y-(y&-y)>=x;y-=(y&-y))
				ans=min(ans,Min[y]);
		}
		return ans;
	}
}A;

int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        int x;
        A.init(n);
        for(int i=1;i<=n;i++)
        {
            S1(x);
            if(i-x<0)
                b[i]=1;
            else
                b[i]= i-x;
            A.update(i,b[i]);
        }
        int ans=1;

        for(int i=n-1;i>=1;i--)
        {
           // printf("%d\n",A.Qmin(i,n));
            if(i<A.Qmin(i+1,n))
            {
                ans++;
             //   printf("**\n");
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
    long long int n, vivos = 1, clawL;
    cin >> n;

    int line[n];
    for(int i = 0; i < n; i++)
        cin >> line[i];

    clawL =  line[n-1];
    for(int i = n-2; i >= 0; i--) {
        if (!clawL)
            vivos++;

        if (line[i] >= clawL)
            clawL = line[i];
        else
            clawL--;

        if(clawL < 0)
            clawL = 0;
    }

    cout << vivos;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

long long int line[1000000];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);

    long long int n, vivos = 1, clawL;
    cin >> n;

    for(int i = 0; i < n; i++)
        cin >> line[i];

    clawL =  line[n-1];
    for(long long int i = n-2; i >= 0; i--) {
        if (clawL == 0)
            vivos++;

        if (line[i] >= clawL)
            clawL = line[i];
        else
            clawL--;

        if(clawL < 0)
            clawL = 0;
    }

    cout << vivos;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
    int n, vivos = 1, clawL;
    cin >> n;

    int line[n];
    for(int i = 0; i < n; i++)
        cin >> line[i];

    clawL =  line[n-1];
    for(int i = n-2; i >= 0; i--) {
        if (!clawL)
            vivos++;

        if (line[i] >= clawL)
            clawL = line[i];
        else
            clawL--;

        if(clawL < 0)
            clawL = 0;
    }

    cout << vivos;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

long long int line[1000000];

int main() {
    long long int n, vivos = 1, clawL;
    cin >> n;

    for(int i = 0; i < n; i++)
        cin >> line[i];

    clawL =  line[n-1];
    for(int i = n-2; i >= 0; i--) {
        if (!clawL)
            vivos++;

        if (line[i] >= clawL)
            clawL = line[i];
        else
            clawL--;

        if(clawL < 0)
            clawL = 0;
    }

    cout << vivos;
    return 0;
}


#include<iostream>
#include<algorithm>
#include<climits>
using namespace std;
int a[1000010];
int main()
{
    cin.sync_with_stdio(0);
    cin.tie(0);
    int n;
    int ans = 0, mi;
    cin >> n;
    mi = n;
    for(int i = 1; i <= n; ++i)
        cin >> a[i];
    for(int i = n; i >= 2; --i)
     {
        //cout << "ans = " << ans << ", mi = " << mi << "\n";
        if(!a[i])
            mi = min(mi, i - 1);
        else if(i - a[i] <= 0)
         {
            ans += max(min(mi, i) - 1, 0);
            mi = 0;
         }
        else if(mi > i - a[i])
        {
            ans += mi - i + a[i];
            mi = i - a[i];
        }
     }
    cout << n - ans << "\n";
}


#include<iostream>
#include<algorithm>
#include<climits>
using namespace std;
long long int a[1000010];
int main()
{
    long long int n;
    long long int ans = 0, mi;
    cin >> n;
    mi = n;
    for(int i = 1; i <= n; ++i)
        cin >> a[i];
    for(long long int i = n; i >= 2; --i)
     {
        if(i - a[i] <= 0)
         {
            ans += max(min(mi, i) - 1, 0LL);
            mi = 0;
         }
        else if(a[i] && (mi > i - a[i]))
        {
            ans += mi - i + a[i];
            mi = i - a[i];
        }
        //cout << "ans = " << ans << ", mi = " << mi << "\n";
     }
    cout << n - ans << "\n";
}


# brute force baby !!!!
from sys import stdin
node,edge = map(int,input().split())
capt = [0]*node
for l in stdin.readlines():
    a,b = map(int,l.split())
    capt[a-1] +=1; capt[b-1] += 1
ones,twos = capt.count(1),capt.count(2)
if ones == node - 1:
    print('star topology')
elif twos == node:
    print('ring topology')
elif ones == 2 and twos == node - 2:
    print('bus topology')
else:
    print('unknown topology')


def star(graph, n, m):
	if m != n - 1:
		return False

	for k in graph:
		if k == n - 1:
			return True

	return False

def bus(graph):
	c = 2
	for k in graph:
		if k == 1:
			c -= 1
		elif k != 2:
			return False

	return c == 0

def ring(graph):
	for k in graph:
		if k != 2:
			return False

	return True

def solve(graph, n, m):
	if bus(graph):
		return 'bus topology'
	if star(graph, n, m):
		return 'star topology'
	if ring(graph):
		return 'ring topology'

	return 'unknown topology'

n, m = map(int, input().split())
graph = [0] * n

for _ in range(m):
	u, v = map(lambda x: int(x) - 1, input().split())
	graph[u] += 1
	graph[v] += 1

print(solve(graph, n, m))


def checkTopology(network, n, e):
	if e == n-1:
		#bus
		if sum([len(y)==1 for x,y in network.items()]) == 2:
			return "bus"
		#star
		elif any([len(y)==e for x, y in network.items()]):
			return "star"
	elif e == n:
		#ring
		if all([len(y)==2 for x, y in network.items()]):
			return "ring"
	return "unknown"\

nodes, edges = [int(x) for x in input().split()]

connections = {}

for n in range(1, nodes+1):
	connections[n] = []

for e in range(edges):
	n, m = [int(x) for x in input().split()]
	connections[n].append(m)
	connections[m].append(n)

#print(connections)

print(checkTopology(connections, nodes, edges), "topology")


import sys
from collections import defaultdict

def bus(graph):
    x = None
    y = None

    for k, v in graph.items():
        if len(v) == 1:
            x = k
            y = v[0]
            break

    while y in graph:
        if len(graph[y]) == 1:
            if graph[y][0] == x:
                return True
            else:
                return False
        else:
            a, b = graph[y]

            if a == x:
                x = y
                y = b
            else:
                x = y
                y = a

    return False

def ring(graph):
    k = next(iter(graph))
    v = graph[k]

    if len(v) != 2:
        return False
    else:
        x, y = v

        while y in graph:
            temp = y
            a, b = graph[y]

            if a == x:
                x = y
                y = b
            else:
                x = y
                y = a

            del graph[temp]

        if len(graph) == 0:
            return True
        else:
            return False

def star(graph):
    count = 0

    for k, v in graph.items():
        if len(v) != 1:
            for i in v:
                if i in graph and len(graph[i]) == 1 and graph[i][0] == k:
                    count += 1

    if len(graph) == count + 1:
        return True
    else:
        return False

if __name__ == '__main__':
    n, m = list(map(int, sys.stdin.readline().split()))
    graph = defaultdict(list)

    for i in range(0, m):
        x, y = list(map(int, sys.stdin.readline().split()))
        graph[x].append(y)
        graph[y].append(x)

    failure = True

    try:
        if star(graph):
            print('star topology')
            failure = False
    except:
        pass

    if failure:
        try:
            if bus(graph):
                print('bus topology')
                failure = False
        except:
            pass

    if failure:
        try:
            if ring(graph):
                print('ring topology')
                failure = False
        except:
            pass

    if failure:
        print('unknown topology')


#!/usr/bin/python3

n, m = [int(x) for x in input().split()]
degree = {0:0, 1:0, 2:0, n - 1:0}
visited = [0] * n
adjlist = [[] for x in range(n)]
for i in range(m):
	x, y = [int(x) for x in input().split()]
	x -= 1
	y -= 1
	adjlist[x].append(y)
	adjlist[y].append(x)

for i in range(n):
	cur_degree = len(adjlist[i])
	if cur_degree not in degree:
		degree[cur_degree] = 1
	else:
		degree[cur_degree] += 1

degree_other = False

for val in degree.keys():
	if val != 1 and val != 2 and val != n - 1 and val != 0:
		degree_other = True

if degree_other == True:
	print("unknown topology")
elif degree[1] == n - 1 and degree[n - 1] == 1:
	print("star topology")
elif degree[1] == 2 and degree[2] == n - 2:
	print("bus topology")
elif degree[2] == n:
	print("ring topology")
else:
	print("unknown topology")


n,m=map(int,input().split())
if n > m+1 or n < m:
	print("unknown topology")
	# because, we know the graph has either n or n-1 edges
	exit()
array = []
for i in range(m):
	a,b = map(int,input().split())
	array.append([a,b])
list_of_edges = [[] for _ in range(n)]
for pair in array:
	a,b = map(int, pair)
	list_of_edges[a-1].append([a,b])
	list_of_edges[b-1].append([b,a]) # because you don't know which way
if n == m: # so, either cyclic or unknown
	def traverse(list_of_edges, node, prev):
		if len(list_of_edges[node-1]) != 2:
			print("unknown topology")
			exit()
		for pair in list_of_edges[node-1]:
			if pair != [node, prev]:
				return [pair[1], pair[0]] # the successor
	num = [1,-1]
	for index in range(n):
		num = traverse(list_of_edges, num[0], num[1])
		if num[0] == 1 and index != n-1:
			print("unknown topology")
			exit()
	if num[0] == 1:
		print("ring topology")
		exit()
	else:
		print("unknown topology")
		exit()
else:
	# so here, we need to check either for the bus or the other one
	# first check for star
	leaf = 0
	is_star = True
	for i in list_of_edges:
		if len(i) not in [1, n-1]:
			is_star = False
		if len(i) == 1:
			leaf = i[0]
			leaf.reverse()
	if is_star:
		print("star topology")
		exit()
	# else it could be the bus
	def line_traverse(list_of_edges, node, prev):
		if len(list_of_edges[node-1]) not in [1,2]:
			print("unknown topology")
			exit()
		for pair in list_of_edges[node-1]:
			if pair != [node, prev]:
				return [pair[1], pair[0]] # the successor

	num = leaf
	for index in range(n-2):
		num = line_traverse(list_of_edges, num[0], num[1])
		if num[0] == leaf[1]:
			print("unknown topology")
			exit()
	print("bus topology")


n,m=map(int,input().split())
if n > m+1 or n < m:
	print("unknown topology")
	# because, we know the graph has either n or n-1 edges
	exit()
array = []
for i in range(m):
	a,b = map(int,input().split())
	array.append([a,b])
list_of_edges = [[] for _ in range(n)]
for pair in array:
	a,b = map(int, pair)
	list_of_edges[a-1].append([a,b])
	list_of_edges[b-1].append([b,a]) # because you don't know which way
if n == m: # so, either cyclic or unknown
	def traverse(list_of_edges, node, prev):
		if len(list_of_edges[node-1]) != 2:
			print("unknown topology")
			exit()
		for pair in list_of_edges[node-1]:
			if pair != [node, prev]:
				return [pair[1], pair[0]] # the successor
	num = [1,-1]
	print(num)
	for index in range(n):
		num = traverse(list_of_edges, num[0], num[1])
		print(num)
		if num[0] == 1 and index != n-1:
			print("shit")
			print("unknown topology")
			exit()
	if num[0] == 1:
		print("ring topology")
		exit()
	else:
		print("unknown topology")
		exit()
else:
	# so here, we need to check either for the bus or the other one
	# first check for star
	leaf = 0
	is_star = True
	for i in list_of_edges:
		if len(i) not in [0, n-1]:
			is_star = False
		if len(i) == 1:
			leaf = 0
			break
	if is_star:
		print("star topology")
		exit()

	# else it could be the bus
	def line_traverse(list_of_edges, node, prev):
		if len(list_of_edges[node-1]) not in [1,2]:
			print("unknown topology")
			exit()
		for pair in list_of_edges[node-1]:
			if pair != [node, prev]:
				return [pair[1], pair[0]] # the successor

	num = [leaf, -1]
	for index in range(n-2):
		num = line_traverse(list_of_edges, num[0], num[1])
		if num[0] == 1:
			print("unknown topology")
			exit()
	print("bus topology")


n,m=map(int,input().split())
if n > m+1 or n < m:
	print("unknown topology")
	# because, we know the graph has either n or n-1 edges
	exit()
array = []
for i in range(m):
	a,b = map(int,input().split())
	array.append([a,b])
list_of_edges = [[] for _ in range(n)]
for pair in array:
	a,b = map(int, pair)
	list_of_edges[a-1].append([a,b])
	list_of_edges[b-1].append([b,a]) # because you don't know which way
if n == m: # so, either cyclic or unknown
	def traverse(list_of_edges, node, prev):
		if len(list_of_edges[node-1]) != 2:
			print("unknown topology")
			exit()
		for pair in list_of_edges[node-1]:
			if pair != [node, prev]:
				return [pair[1], pair[0]] # the successor
	num = [1,-1]
	for index in range(n):
		num = traverse(list_of_edges, num[0], num[1])
		if num[0] == 1 and index != n-1:
			print("unknown topology")
			exit()
	if num[0] == 1:
		print("ring topology")
		exit()
	else:
		print("unknown topology")
		exit()
else:
	# so here, we need to check either for the bus or the other one
	# first check for star
	leaf = 0
	is_star = True
	for i in list_of_edges:
		if len(i) not in [1, n-1]:
			is_star = False
		if len(i) == 1:
			leaf = i[0]
			leaf.reverse()
	if is_star:
		print("star topology")
		exit()
	# else it could be the bus
	def line_traverse(list_of_edges, node, prev):
		if len(list_of_edges[node-1]) not in [1,2]:
			print("unknown topology")
			exit()
		for pair in list_of_edges[node-1]:
			if pair != [node, prev]:
				return [pair[1], pair[0]] # the successor

	num = leaf
	for index in range(n-3):
		num = line_traverse(list_of_edges, num[0], num[1])
		if num[0] == 1:
			print("unknown topology")
			exit()
	print("bus topology")


n,m=map(int,input().split())
if n > m+1 or n < m:
	print("unknown topology")
	# because, we know the graph has either n or n-1 edges
	exit()
array = []
for i in range(m):
	a,b = map(int,input().split())
	array.append([a,b])
list_of_edges = [[] for _ in range(n)]
for pair in array:
	a,b = map(int, pair)
	list_of_edges[a-1].append([a,b])
	list_of_edges[b-1].append([b,a]) # because you don't know which way
if n == m: # so, either cyclic or unknown
	def traverse(list_of_edges, node, prev):
		if len(list_of_edges[node-1]) != 2:
			print("unknown topology")
			exit()
		for pair in list_of_edges[node-1]:
			if pair != [node, prev]:
				return [pair[1], pair[0]] # the successor
	num = [1,-1]
	print(num)
	for index in range(n):
		num = traverse(list_of_edges, num[0], num[1])
		if num[0] == 1 and index != n-1:
			print("unknown topology")
			exit()
	if num[0] == 1:
		print("ring topology")
		exit()
	else:
		print("unknown topology")
		exit()
else:
	# so here, we need to check either for the bus or the other one
	# first check for star
	leaf = 0
	is_star = True
	for i in list_of_edges:
		if len(i) not in [0, n-1]:
			is_star = False
		if len(i) == 1:
			leaf = 0
			break
	if is_star:
		print("star topology")
		exit()

	# else it could be the bus
	def line_traverse(list_of_edges, node, prev):
		if len(list_of_edges[node-1]) not in [1,2]:
			print("unknown topology")
			exit()
		for pair in list_of_edges[node-1]:
			if pair != [node, prev]:
				return [pair[1], pair[0]] # the successor

	num = [leaf, -1]
	for index in range(n-2):
		num = line_traverse(list_of_edges, num[0], num[1])
		if num[0] == 1:
			print("unknown topology")
			exit()
	print("bus topology")


n,m=map(int,input().split())
if n > m+1 or n < m:
	print("unknown topology")
	# because, we know the graph has either n or n-1 edges
	exit()
array = []
for i in range(m):
	a,b = map(int,input().split())
	array.append([a,b])
list_of_edges = [[] for _ in range(n)]
for pair in array:
	a,b = map(int, pair)
	list_of_edges[a-1].append([a,b])
	list_of_edges[b-1].append([b,a]) # because you don't know which way
if n == m: # so, either cyclic or unknown
	def traverse(list_of_edges, node, prev):
		if len(list_of_edges[node-1]) != 2:
			print("unknown topology")
			exit()
		for pair in list_of_edges[node-1]:
			if pair != [node, prev]:
				return [pair[1], pair[0]] # the successor
	num = [1,-1]
	for index in range(n):
		num = traverse(list_of_edges, num[0], num[1])
		if num[0] == 1 and index != n-1:
			print("unknown topology")
			exit()
	if num[0] == 1:
		print("ring topology")
		exit()
	else:
		print("unknown topology")
		exit()
else:
	# so here, we need to check either for the bus or the other one
	# first check for star
	leaf = 0
	is_star = True
	for i in list_of_edges:
		if len(i) not in [1, n-1]:
			is_star = False
		if len(i) == 1:
			leaf = 0
			break
	if is_star:
		print("star topology")
		exit()

	# else it could be the bus
	def line_traverse(list_of_edges, node, prev):
		if len(list_of_edges[node-1]) not in [1,2]:
			print("unknown topology")
			exit()
		for pair in list_of_edges[node-1]:
			if pair != [node, prev]:
				return [pair[1], pair[0]] # the successor

	num = [leaf, -1]
	for index in range(n-2):
		num = line_traverse(list_of_edges, num[0], num[1])
		if num[0] == 1:
			print("unknown topology")
			exit()
	print("bus topology")


n,m=map(int,input().split())
if n > m+1 or n < m:
	print("unknown topology")
	# because, we know the graph has either n or n-1 edges
	exit()
array = []
for i in range(m):
	a,b = map(int,input().split())
	array.append([a,b])
list_of_edges = [[] for _ in range(n)]
for pair in array:
	a,b = map(int, pair)
	list_of_edges[a-1].append([a,b])
	list_of_edges[b-1].append([b,a]) # because you don't know which way
if n == m: # so, either cyclic or unknown
	def traverse(list_of_edges, node, prev):
		if len(list_of_edges[node-1]) != 2:
			print("unknown topology")
			exit()
		for pair in list_of_edges[node-1]:
			if pair != [node, prev]:
				return [pair[1], pair[0]] # the successor
	num = [1,-1]
	for index in range(n):
		num = traverse(list_of_edges, num[0], num[1])
		if num[0] == 1 and index != n-1:
			print("unknown topology")
			exit()
	if num[0] == 1:
		print("ring topology")
		exit()
	else:
		print("unknown topology")
		exit()
else:
	# so here, we need to check either for the bus or the other one
	# first check for star
	leaf = 0
	is_star = True
	for i in list_of_edges:
		if len(i) not in [0, n-1]:
			is_star = False
		if len(i) == 1:
			leaf = 0
			break
	if is_star:
		print("star topology")
		exit()

	# else it could be the bus
	def line_traverse(list_of_edges, node, prev):
		if len(list_of_edges[node-1]) not in [1,2]:
			print("unknown topology")
			exit()
		for pair in list_of_edges[node-1]:
			if pair != [node, prev]:
				return [pair[1], pair[0]] # the successor

	num = [leaf, -1]
	for index in range(n-2):
		num = line_traverse(list_of_edges, num[0], num[1])
		if num[0] == 1:
			print("unknown topology")
			exit()
	print("bus topology")


import sys
from math import *

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())

n, m = mints()
e = [[] for i in range(n+1)]

def isstar():
	c = None
	for i in range(1, n+1):
		if len(e[i]) > 1:
			if c != None:
				return False
			c = i
	if c == None:
		return False
	#for i in range(1,n+1)
	#	if i != c and e[i][0] != i:
	return len(e[c]) == n-1

def isbus():
	c = None
	for i in range(1, n+1):
		if len(e[i]) == 1:
			c = i
	if c == None:
		return False
	cnt = 2
	p = c
	c = e[c][0]
	while len(e[c]) == 2:
		if e[c][0] == p:
			p = c
			c = e[c][1]
		else:
			p = c
			c = e[c][0]
	return len(e[c]) == 1

def isring():
	p = 1
	if len(e[1]) != 2:
		return False
	c = e[1][0]
	while len(e[c]) == 2 and c != 1:
		if e[c][0] == p:
			p = c
			c = e[c][1]
		else:
			p = c
			c = e[c][0]
	return c == 1

for i in range(m):
	a, b = mints()
	e[a].append(b)
	e[b].append(a)
if isstar():
	print("star topology")
elif isbus():
	print("bus topology")
elif isring():
	print("ring topology")
else:
	print("unknown topology")


n ,m = map(int, input().split(' '))

l=[]

for i in range(m):
	l.append(list(map(int, input().split(' '))))

ppp=0

if(n-m==1 and ppp==0):
	s = set(l[0]).intersection(set(l[1]), set(l[2]))

	if(len(s)==1):
		common = list(s)[0]
		p=0

		for a in l:
			if(common not in a):
				p=1

		if(p==0 and ppp==0):
			print('star topology')
			ppp=1

		elif(ppp==0):
			print('unknown topology')
			ppp=1

	elif(len(s)==0):
		adj = [[0]*n for i in range(n)]

		for a in l:
			adj[a[0]-1][a[1]-1]=1
			adj[a[1]-1][a[0]-1]=1

		sums = [sum(p) for p in adj]

		if(sums.count(1)==2 and sums.count(2)==n-2 and ppp==0):
			print('bus topology')
			ppp=1
		elif(ppp==0):
			print('unknown topology')
			ppp=1

	elif(ppp==0):
		print('unknown topology')
		ppp=1

elif(n==m and ppp==0):
		adj = [[0]*n for i in range(n)]

		for a in l:
			adj[a[0]-1][a[1]-1]=1
			adj[a[1]-1][a[0]-1]=1

		sums = [sum(p) for p in adj]

		if(sums.count(2)==n and ppp==0):
			print('ring topology')
			ppp=1
		elif(ppp==0):
			print('unknown topology')
			ppp=1

elif(ppp==0):
	print('unknown topology')


n, m=map(int, input().split())
a=[0]*n
for i in range(m):
	x, y=map(int, input().split())

	a[x-1]+=1
	a[y-1]+=1

s=set(a)
if(s=={2}):print('ring')
elif(s=={1, 2}):
	print('bus')
elif(s=={1, m}):
	print('star')
else:
	print('unknown')
print(' topology')


R = lambda: map(int, input().split())
n, m = R()
c = [0] * n
for i in range(m):
  x, y = R()
  c[x - 1] += 1
  c[y - 1] += 1
c1 = c2 = 0
for i in range(n):
  if c[i] == 1:
    c1 += 1
  elif c[i] == 2:
    c2 += 1
if c2 == n:
  print("ring topology")
elif c1 == 2 and c2 == n - 2:
  print("bus topology")
elif c1 == n - 1:
  print("star topology")
else:
  print("unknown topology")


mod = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
bt,rt,st=1,1,1
n,m=f()
l=[sorted(il()) for _ in range(m)]
l.sort()
for i in range(m-1):
    if l[i][1]!=l[i+1][0]:
        bt=0
if bt==1 and l[-1][1]!=l[0][0]:
    rt=0
if bt==1 and l[-1][1]==l[0][0]:
    bt=0
if bt==0:
    rt=0
x=0
if l[0][0]==l[1][0] or l[0][0]==l[1][1]:
    x=l[0][0]
else:
    x=l[0][1]
if any(i[0]!=x and i[1]!=x for i in l):
    st=0
if bt==1:
    print('bus topology')
elif rt==1:
    print('ring topology')
elif st==1:
    print('star topology')
else:
    print('unknown topology')


mod = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
bt,rt,st=1,0,1
n,m=f()
l=[il() for _  in range(m)]
l.sort()
for i in range(m-1):
    if l[i][1]!=l[i+1][0]:
        bt=0

if bt==1 and l[-1][1]==l[0][0]:
    rt=1
    bt=0
x=0
if l[0][0]==l[1][0] or l[0][0]==l[1][1]:
    x=l[0][0]
else:
    x=l[0][1]
if any(i[0]!=x and i[1]!=x for i in l):
    st=0
if bt==1:
    print('bus topology')
elif rt==1:
    print('ring topology')
elif st==1:
    print('star topology')
else:
    print('unknown topology')


mod = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
n,m=f()
l=[0]*n
for _ in range(m):
    a,b=f()
    l[a-1]+=1
    l[b-1]+=1
l.sort()
if l[0]==1 and l[1]==1 and all(i==2 for i in l[2:]):
    print('bus topology')
elif all(i==2 for i in l):
    print('ring topology')
elif all(i==1 for i in l[:n-1]) and l[-1]==n-1:
    print('star topology')
else:
    print('unknown topology')


n,m=map(int,input().split())
graph={}
for i in range(1,n+1):
    graph[i]=[]
for i in range(m):
    u,v=map(int,input().split())
    graph[u].append(v)
    graph[v].append(u)
c=0
d=0
#print(graph)
for i in range(1,n+1):
    if len(graph[i])==1:
        c=c+1
    elif len(graph[i])>=2:
        d=d+1
if m==n-1 and c==2 and d==n-2:
    print("bus topology")
elif c==0 and d==n and m==n:
    print("ring topology")
elif c==n-1 and d==1:
    print("star topology")
else:
    print("unknown topology")


n,m=map(int,input().split())
graph={}
for i in range(1,n+1):
    graph[i]=[]
for i in range(m):
    u,v=map(int,input().split())
    graph[u].append(v)
    graph[v].append(u)
c=0
d=0
#print(graph)
for i in range(1,n+1):
    if len(graph[i])==1:
        c=c+1
    elif len(graph[i])>=2:
        d=d+1
if m==n-1:
    print("bus topology")
elif c==0 and d==n and m==n:
    print("ring topology")
elif c==n-1 and d==1 and m==n:
    print("star topology")
else:
    print("unknown topology")


n,m=map(int,input().split())
graph={}
for i in range(1,n+1):
    graph[i]=[]
for i in range(m):
    u,v=map(int,input().split())
    graph[u].append(v)
    graph[v].append(u)
c=0
d=0
#print(graph)
for i in range(1,n+1):
    if len(graph[i])==1:
        c=c+1
    elif len(graph[i])>=2:
        d=d+1
if c==2 and d==n-2:
    print("bus topology")
elif c==0 and d==n:
    print("ring topology")
elif c==n-1 and d==1:
    print("star topology")
else:
    print("unknown topology")


n,m=map(int,input().split())
graph={}
for i in range(1,n+1):
    graph[i]=[]
for i in range(m):
    u,v=map(int,input().split())
    graph[u].append(v)
    graph[v].append(u)
c=0
d=0
#print(graph)
for i in range(1,n+1):
    if len(graph[i])==1:
        c=c+1
    elif len(graph[i])>=2:
        d=d+1
if m==n-1 and c==2 and d==n-2:
    print("bus topology")
elif c==0 and d==n and m==n:
    print("ring topology")
elif c==n-1 and d==1 and m==n:
    print("star topology")
else:
    print("unknown topology")


#!/usr/bin/env python3
# -*- coding: utf-8 -*-

n, m = map(int, input().split())
g = [[] for i in range(n)]
for i in range(m):
    x, y = map(int, input().split())
    x -= 1; y -= 1
    g[x].append(y); g[y].append(x)
g = [len(g[i]) for i in range(n)]
if g.count(2) == n - 2 and g.count(1) == 2:
    print('bus topology')
elif g.count(2) == n:
    print('ring topology')
elif g.count(1) == n - 1 and g.count(n - 1) == 1:
    print('star topology')
else:
    print('unknown topology')


#!/usr/bin/env python3
# -*- coding: utf-8 -*-

n, m = map(int, input().split())
g = [[] for i in range(n)]
for i in range(m):
    x, y = map(int, input().split())
    x -= 1; y -= 1
    g[x] = y; g[y] = x
g[i] = [len(g[i]) for i in range(m)]
if g.count(2) == n - 2 and g.count(1) == 2:
    print('bus topology')
elif g.count(2) == n:
    print('ring topology')
elif g.count(1) == n - 1 and g.count(n - 1) == 1:
    print('star topology')
else:
    print('unknown topology')


def main():
    n, m = map(int, input().split())
    types = ['bus', 'ring', 'star', 'unknown']

    occ = [0] * n
    for i in range(m):
        a, b = map(int, input().split())
        occ[a-1] += 1
        occ[b-1] += 1

    cnt = [0] * 3
    for v in occ:
        cnt[min(2, v-1)] += 1

    if cnt == [2, n - 2, 0]:
        res = types[0]
    elif cnt == [0, n, 0]:
        res = types[1]
    elif cnt == [n - 1, 0, 1]:
        res = types[2]
    else:
        res = types[3]

    print(res, 'topology')

if __name__ == '__main__':
    main()


from collections import Counter

n, m = map(int, input().split())

g = [[] for _ in range(n)]

for i in range(m):
    x, y = map(int, input().split())
    g[x - 1].append(y - 1)
    g[y - 1].append(x - 1)

bus = ([2] * (n - 2)) + ([1] * 2)
star = [1] * (n - 1) + [n - 1]

lns = [len(lst) for lst in g]
if lns == [2] * n:
    print("ring topology")
elif Counter(lns) == Counter(bus):
    print("bus topology")
elif Counter(lns) == Counter(star):
    print("star topology")
else:
    print("unknown topology")


n,m=map(int,input().split())
l=[0]*n
d=l[:]
for _ in range(m):
    a,b=map(int,input().split())
    l[a-1]+=1
    l[b-1]+=1
for i in l:
    d[i]+=1
if(d[1]==2 and d[2]==n-2):
    print('bus topology')
elif(d[2]==n):
    print('ring topology')
elif(d[1]==n-1 and d[n-1]==1):
    print('star topology')
else:
    print('unknown topology')


n,m=map(int,input().split())
l=[0]*n
for i in range(m):
	x,y=map(int,input().split())
	l[x-1]+=1
	l[y-1]+=1

l.sort()
if [1]*2+[2]*(n-2)==l:
	print("bus topology")
elif [2]*n==l:
	print("ring topology")
elif [1]*(n-1)+[n-1]==l:
	print("star topology")
else:
	print("unknown topology")


n,m=list(map(int,input().split()))
d=dict()
for i in range(m):
    x,y=list(map(int,input().split()))
    if x in d:
        d[x].add(y)
    else:
        d[x]=set()
        d[x].add(y)
    if y in d:
        d[y].add(x)
    else:
        d[y]=set()
        d[y].add(x)

x=0
y=0
z=0
for i in d:
    if len(d[i])==1:
        x+=1
    elif len(d[i])==2:
        y+=1
    elif len(d[i])==m:
        z+=1

if x==n-1 and y==0 and z==1:
    print("star topology")
elif x==2 and y==n-2 and z==0:
    print("bus topology")
elif x==0 and y==n and z==0:
    print("ring topology")
else:
    print("unknown topology")


import sys
import math
n,m=map(int,input().split())

degree=[0]*(n+1)

for _ in range(0,int(m)):
    a,b=map(int,input().split())
    degree[a]=degree[a]+1
    degree[b]=degree[b]+1

if degree.count(1)==2 and degree.count(2)==n-2:
    print('bus topology')
elif degree.count(2)==n:
    print('ring topology')
elif degree.count(1)==n-1 and degree.count(n-1)==1:
    print('star topology')
else:
    print('unknown topology')


n,m = map(int,input().split())
a = []
for h in range(0,n+1):
    a.append([])
for i in range(m):
    k,j = map(int,input().split())
    a[k].append(j)
    a[j].append(k)
d2 = 0
d1 = 0
d3 = 0
for u in a:
    if len(u) == 1 :
        d1+=1
    if len(u) == 2 :
        d2+=1
    if len(u) == n-1:
        d3+=1
if d1 == 2 and d2 = n-2:
    print("bus topology")
elif d3 == 1 and d1 == n-1:
    print("star topology")
elif d2 == n:
    print("ring topology")
else:
    print("unknown topology")


n,m = map(int,input().split())
a = []
for h in range(0,n+1):
    a.append([])
for i in range(m):
    k,j = map(int,input().split())
    a[k].append(j)
    a[j].append(k)
d2 = 0
d1 = 0
d3 = 0
for u in a:
    if len(u) == 1 :
        d1+=1
    if len(u) == 2 :
        d2+=1
    if len(u) == n-1:
        d3+=1
if d1 == 2 and d2 == n-2:
    print("bus topology")
elif d3 == 1 and d1 == n-1:
    print("star topology")
elif d2 == n:
    print("ring topology")
else:
    print("unknown topology")


n,m = map(int,input().split())
a = []
for h in range(0,n+1):
    a.append([])
for i in range(m):
    k,j = map(int,input().split())
    a[k].append(j)
    a[j].append(k)
d2 = 0
d1 = 0
d3 = 0
for u in a:
    if len(u) == 1 :
        d1+=1
    if len(u) == 2 :
        d2+=1
    if len(u) == n-1:
        d3+=1
if d1 == 2 and d2 > 1:
    print("bus topology")
if d3 == 1:
    print("star topology")
if d2 == n:
    print("ring topology")


n,m = map(int,input().split())
a = []
for h in range(0,n+1):
    a.append([])
for i in range(m):
    k,j = map(int,input().split())
    a[k].append(j)
    a[j].append(k)
d2 = 0
d1 = 0
d3 = 0
for u in a:
    if len(u) == 1 :
        d1+=1
    if len(u) == 2 :
        d2+=1
    if len(u) == n-1:
        d3+=1
if d1 == 2:
    print("bus topology")
elif d3 == 1:
    print("star topology")
elif d2 == n:
    print("ring topology")
else:
    print("unknown topology")


n, m = [int(k) for k in input().split()]
ans = 'bus topology'
dict = {}
count = 0
t = 0
if m >= n-1:
    for i in range(m):
        first, second = [int(k) for k in input().split()]
        if first not in dict:
            dict[first] = set()
            dict[first].add(second)
        else:
            if len(dict[first]) == 1:
                count += 1
            else: t += 1
            dict[first].add(second)
        if second not in dict:
            dict[second] = set()
            dict[second].add(first)
        else:
            if len(dict[second]) == 1:
                count += 1
            else: t += 1
            dict[second].add(first)
if count == n-2 and m == n-1:
    print('bus topology')
elif count == 1:
    print('star topology')
elif count == n and t == 0:
    print('ring topology')
else:
    print('unknown topology')


n, m = [int(k) for k in input().split()]
ans = 'bus topology'
dict = {}
count = 0
if m >= n-1:
    for i in range(m):
        first, second = [int(k) for k in input().split()]
        if first not in dict:
            dict[first] = set()
            dict[first].add(second)
        else:
            if len(dict[first]) == 1:
                count += 1
            dict[first].add(second)
        if second not in dict:
            dict[second] = set()
            dict[second].add(first)
        else:
            if len(dict[second]) == 1:
                count += 1
            dict[second].add(first)
if count == n-2 and m == n-1:
    print('bus topology')
elif count == 1:
    print('star topology')
elif count == n:
    print('ring topology')
else:
    print('unknown topology')


n,m=map(int,input().split())

c=[0 for _ in range(n)]

for _ in range(m):
    a,b=map(int,input().split())
    c[a-1]+=1
    c[b-1]+=1

s=set(c)
res="unknown"
if s=={2}:
    res="ring"
elif s=={1,2}:
    res="bus"
elif s=={1,m}:
    res="star"

print(res+" topology")


n, m = [int(k) for k in input().split()]
ans = 'bus topology'
dict = {}
count = 0
if m >= n-1:
    for i in range(m):
        first, second = [int(k) for k in input().split()]
        if first not in dict:
            dict[first] = set()
            dict[first].add(second)
        else:
            if len(dict[first]) == 1:
                count += 1
            dict[first].add(second)
        if second not in dict:
            dict[second] = set()
            dict[second].add(first)
        else:
            if len(dict[first]) == 1:
                count += 1
            dict[second].add(first)
if count == n-2 and m == n-1:
    print('bus topology')
elif count == 1:
    print('star topology')
elif count == n-1:
    print('ring topology')
else:
    print('unknown topology')


n, m = map(int, input().split())
a = []
for i in range(0, n+1):
    a.append([])
for i in range(m):
    i, j = map(int, input().split())
    a[i].append(j)
    a[j].append(i)
c = 0
d = 0
f = 0
for el in a:
    if(len(el)==1):
        c+=1
    elif(len(el)==2):
        d+=1
    elif(len(el)==n-1):
        f+=1
if(c==2 and d==n-2):
    print("bus topology")
elif(d==n):
    print("ring topology")
elif(f==1 and c==n-1):
    print("star topology")
else:
    print("unknown topology")


from collections import defaultdict,Counter
N,M = map(int, input().split())
AdjList = defaultdict(int)
for i in range(M):
    a,b = map(int,input().split())
    AdjList[a] += 1
    AdjList[b] += 1
CheckList = []
for i in AdjList.values():
    CheckList.append(i)
Freq = Counter(CheckList)
if(len(Freq.values()) == 1 and Freq[2]!=0):
    print("ring topology")
elif(len(Freq.values()) == 2 and Freq[1]==2 and Freq[2]!=0):
    print("bus topology")
elif(len(Freq.values())== 2 and Freq[1]==N-1):
    print("star topology")
else:
    print("unknown topology")


n, m = map(int, input().split())
last = 0
line = True
parents = set()

for i in range(m):
    x, y = map(int, input().split())
    if i and (last != x or x > y):
        line = False
    last = y
    parents.add(x)

if line:
        print("bus topology")
elif y == 1:
        print("ring topology")
elif len(parents) == 1:
    print("star topology")
else:
    print("unknown topology")


n, m = map(int, input().split())
d = [0]*(n+1)

for i in range(m):
    x, y = map(int, input().split())
    d[x] += 1
    d[y] += 1

if d.count(1) == 2 and d.count(2) == n-2:
    print("bus topology")
elif d.count(2) == n:
    print("ring topology")
elif d.count(1) == n-1 and d.count(n-1) == 1:
    print("star topology")
else:
    print("unknown topology")


import re
import itertools
from collections import Counter, deque

class Task:
    n, m = 0, 0
    graph = []
    answer = ""

    def getData(self):
        self.n, self.m = [int(x) for x in input().split(' ')]
        for i in range(0, self.m):
            self.graph += [[int(x) for x in input().split(' ')]]

        #inFile = open('input.txt', 'r')
        #inFile.readline().rstrip()
        #self.childs = inFile.readline().rstrip()

    def solve(self):
        graph = self.graph
        vertexDegrees = [0] * (self.n + 1)
        for edge in graph:
            vertexDegrees[edge[0]] += 1
            vertexDegrees[edge[1]] += 1
        vertexDegrees = vertexDegrees[1:]
        if vertexDegrees.count(2) == len(vertexDegrees):
            self.answer = 'ring topology'
            return
        if vertexDegrees.count(1) == 2 and vertexDegrees.count(2) == \
                len(vertexDegrees) - 2:
            self.answer = 'bus topology'
            return
        if vertexDegrees.count(1) == len(vertexDegrees) - 1:
            self.answer = 'star topology'
            return
        self.answer = 'unknown topology'

    def printAnswer(self):
        print(re.sub(r'[\[\],]', '', str(self.answer)))
        #print(self.answer[:6])
        #outFile = open('output.txt', 'w')
        #outFile.write(self.answer)

task = Task()
task.getData()
task.solve()
task.printAnswer()


n,m=map(int,input().split())
l=[]
for i in range(n):
    l.append(0)
for i in  range(m):
    a,b=map(int,input().split())
    l[a-1]+=1
    l[b-1]+=1
m=list(set(l))
if(len(m)==2 and l[0]==1 and l[len(l)-1]==1 and max(l)==2):
    print('bus topology')
elif(len(m)==1 and max(l)==2):
    print('ring topology')
elif(len(m)==2 and max(l)==n-1 and l.count(min(l))==n-1):
    print('star topology')
else:
    print('unknown topology')


n,m=map(int,input().split())
l=[]
for i in range(n):
    l.append(0)
for i in  range(m):
    a,b=map(int,input().split())
    l[a-1]+=1
    l[b-1]+=1
m=list(set(l))
if(len(m)==2  and max(l)==2 and min(l)==1 and l.count(min(l))==2):
    print('bus topology')
elif(len(m)==1 and max(l)==2):
    print('ring topology')
elif(len(m)==2 and max(l)==n-1 and l.count(min(l))==n-1 and min(l)==1):
    print('star topology')
else:
    print('unknown topology')


def main():
    n, m = map(int, input().split())
    l = [0] * n
    for i in range(m):
        a, b = map(int, input().split())
        l[a - 1] += 1
        l[b - 1] += 1
    k_1 = 0
    k_2 = 0
    k_n  = 0
    for i in range(n):
        if l[i] == 1:
            k_1 += 1
        elif l[i] == 2:
            k_2 += 1
        elif l[i] == n - 1:
            k_n += 1
    if k_1 == 2 and k_2 == n - 2:
        print('bus topology')
    elif k_2 == n:
        print('ring topology')
    elif k_1 == n - 1 and k_n == 1:
        print('star topology')
    else:
        print('unknown topology')

main()


n,m = map(int,input().split())
if n==m or n==m+1:
    s = [0]*n
    for _ in range(m):
        a,b = map(int,input().split())
        s[a-1]+=1
        s[b-1]+=1
    s = set(s)
    if s=={2}:
        print('ring topology')
    elif s == {1, 2}:
        print("bus topology")
    elif s == {1, m}:
        print("star topology")
    else:
        print('unknown topology')
else:
    print('unknown topology')
    exit(0)


n,m = map(int,input().split())
if n==m or n==m+1:
    s = [0]*n
    for _ in range(m):
        a,b = map(int,input().split())
        s[a-1]+=1
        s[b-1]+=1
    s = set(s)
    if s=={2}:
        print('ring topology')
    elif s == {1, 2}:
        print("bus topolog")
    elif s == {1, m}:
        print("star topolog")
    else:
        print('unknown topology')
else:
    print('unknown topology')
    exit(0)


x,y = 0,0
countZero = 0
countOne = 0

n,m = [int(i) for i in input().split()]
a = [0]*n

for i in range(m):
    x,y = [int(i) for i in input().split()]
    a[y-1]+=1
    a[x-1]+=1

for i in a:
        if i==1:
            countZero+=1
        elif i>1:
            countOne+=1

if n==m:
    if countZero==0 and countOne==n:
        print('ring topology')
    else:
        print('unknown topology')
elif n-m==1:
    if countZero==2 and countOne==n-2:
        print('bus topology')
    elif countZero==n-1 and countOne==1:
        print('star topology')
    else:
        print('unknown topology')


x,y = 0,0
countZero = 0
countOne = 0

n,m = [int(i) for i in input().split()]
a = [0]*n

for i in range(m):
    x,y = [int(i) for i in input().split()]
    a[y-1]+=1
    a[x-1]+=1

for i in a:
        if i==1:
            countZero+=1
        elif i>1:
            countOne+=1

if n==m:
    if countZero==0 and countOne==n:
        print('ring topology')
    else:
        print('unknown topology')
elif n-m==1:
    if countZero==2 and countOne==n-2:
        print('bus topology')
    elif countZero==n-1 and countOne==1:
        print('star topology')
    else:
        print('unknown topology')
else:
    print('unknown topology')


x,y = 0,0
countZero = 0
countOne = 0

n,m = [int(i) for i in input().split()]
a = [0]*n

for i in range(m):
    x,y = [int(i) for i in input().split()]
    a[y-1]+=1
    a[x-1]+=1

for i in a:
        if i==1:
            countZero+=1
        elif i>1:
            countOne+=1

if n==m:
    if countZero==0 and countOne==n:
        print('ring typology')
    else:
        print('unknown typology')
elif n-m==1:
    if countZero==2 and countOne==n-2:
        print('bus typology')
    elif countZero==n-1 and countOne==1:
        print('star typology')
    else:
        print('unknown typology')


n, m = map(int, input().split())
graph = dict(zip([i + 1 for i in range(n)], [[] for i in range(n)]))
for _ in range(m):
    u, v = map(int, input().split())
    graph[u].append(v)
    graph[v].append(u)
freq = {}
for key in graph:
    if len(graph[key]) in freq:
        freq[len(graph[key])] += 1
    else:
        freq[len(graph[key])] = 1
if len(freq) == 2 and 1 in freq and 2 in freq:
    print('bus topology')
elif len(freq) == 1 and 2 in freq:
    print('ring topology')
elif len(freq) == 2 and 1 in freq and n - 1 in freq:
    print('star topology')
else:
    print('unknown topology')


n, m = map(int, input().split())

vs = [0 for i in range(n)]

for i in range(m):
    x, y = map(int, input().split())
    vs[x - 1] = vs[x - 1] + 1
    vs[y - 1] = vs[y - 1] + 1

if max(vs) == m and n == m + 1:
    print('star topology')
else:
    ones = sum(map(lambda x: 1 if x == 1 else 0, vs))
    if n == m + 1 and ones == 2:
        print('bus topology')
    else:
        doubles = sum(map(lambda x: 1 if x == 2 else 0, vs))
        if n == m and doubles == n:
            print('ring topology')
        else:
            print('unknown topology')


from collections import defaultdict

I = lambda: map(int, input().split())

degrees = defaultdict(int)
n, m = I()

for _ in range(m):
    u, v = I()
    degrees[u] += 1
    degrees[v] += 1

values = set(degrees.values())
answer = 'unknown'

if values == {2}:
    answer = 'ring'
elif values == {1, 2}:
    answer = 'bus'
elif values == {1, m}:
    answer = 'start'

print(answer, 'topology')


from collections import defaultdict

I = lambda: list(map(int, input().split()))

degrees = defaultdict(int)

for _ in range(I()[1]):
    u, v = I()
    degrees[u] += 1
    degrees[v] += 1

values = set(degrees.values())

if values == {1, 2}:
    print('bus topology')
elif values == {2}:
    print('ring topology')
elif len(values) == 2 and 1 in values:
    print('star topology')
else:
    print('unknown topology')


from collections import defaultdict

I = lambda: map(int, input().split())

degrees = defaultdict(int)
n, m = I()

for _ in range(m):
    u, v = I()
    degrees[u] += 1
    degrees[v] += 1

values = set(degrees.values())
answer = 'unknown'

if values == {2}:
    answer = 'ring'
elif values == {1, 2}:
    answer = 'bus'
elif values == {1, m}:
    answer = 'star'

print(answer, 'topology')


n,m=map(int,input().split())
arr=[0]*(n+1)
for w in range(m):
    a,b=map(int,input().split())
    arr[a]+=1
    arr[b]+=1
c1=0
c2=0
cs=0
for i in range(1,n+1):
    if arr[i]==1:
        c1+=1
    if arr[i]==2:
        c2+=1
    if arr[i]==n-1:
        cs+=1
if c1==2 and c2==n-2:
    print("bus topology")
elif c2==n:
    print("ring topology")
elif c1==n-1 and cs==1:
    print("star topology")
else:
    print("unknown topology")


n, m = map(int, input().split())
p = [0] * (n + 1)
for i in range(m):
    a, b = map(int, input().split())
    p[a] += 1
    p[b] += 1

ans = 'unknown topology'
if n == m:
    if p.count(2) == n: ans = 'ring topology'
elif n == m + 1:
    if n - 1 in p: ans = 'star topology'
    elif p.count(1) == 2 and p.count(2) == n - 2: ans = 'bus topology'
print(ans)


n, m = map(int, input().split())
p = [0] * (m + 1)
for i in range(m):
    a, b = map(int, input().split())
    p[a] += 1
    p[b] += 1

ans = 'unknown topology'
if n == m:
    if p.count(2) == n: ans = 'ring topology'
elif n == m - 1:
    if n - 1 in p: ans = 'star topology'
    elif p.count(1) == 2 and p.count(2) == n - 2: ans = 'bus topology'
print(ans)


n,m = map(int,input().split())
v = []
for i in range(n):
    v.append(0)
for i in range(m):
    t1,t2 = map(int,input().split())
    v[t1-1]+=1
    v[t2-1]+=1
if max(v) == 2 and min(v) == 2:
    print("ring topology")
elif set(v) == set([1,2]):
    print("bus topology")
elif set(v) == set([1,max(v)]):
    print("star topology")
else:
    print("unknown topology")


n,m = map(int,input().split())
v = []
def chek_star(v):
    t = 0
    for i in v:
        if i != 1:
            t+=1
    if t == 1:
        return True
    return False
for i in range(n):
    v.append(0)
for i in range(m):
    t1,t2 = map(int,input().split())
    v[t1-1]+=1
    v[t2-1]+=1
if max(v) == 2 and min(v) == 2:
    print("ring topology")
elif set(v) == set([1,2]):
    print("bus topology")
elif set(v) == set([1,max(v)]) and chek_star(v):
    print("star topology")
else:
    print("unknown topology")


n,m = map(int,input().split())
v = []
for i in range(n):
    v.append(0)
for i in range(m):
    t1,t2 = map(int,input().split())
    v[t1-1]+=1
    v[t2-1]+=1
if max(v) == 2 and min(v) == 2:
    print("ring topology")
elif set(v) == set([1,2]):
    print("bus topology")
elif set(v) == set([1,max(v)]):
    print("star topology")
else:
    print("unknow topology")


n,m=map(int,input().split())

l=[0]*n

d=l[:]

for _ in range(m):

    a,b=map(int,input().split())

    l[a-1]+=1

    l[b-1]+=1

for i in l:

    d[i]+=1

if(d[1]==2 and d[2]==n-2):

    print('bus topology')

elif(d[2]==n):

    print('ring topology')

elif(d[1]==n-1 and d[n-1]==1):

    print('star topology')

else:

    print('unknown topology')

# Made By Mostafa_Khaled


n,m=input().split()
n=int(n);m=int(m)
a=[0]*n
for i in range(0,m):
	x,y=input().split()
	x=int(x);y=int(y)
	a[x-1]+=1;a[y-1]+=1
r="unknown"
s=set(a)
if s=={2}:
	r="ring"
if s=={1,2}:
	r="bus"
if s=={1,m}:
	r="star"
print(r,"topology")


import math
import sys
from collections import defaultdict
from collections import Counter
from collections import deque
import bisect
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda: map(int,input().split())
alele = lambda: list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
INF = 10 ** 18
MOD = 10 ** 9 + 7

n,m = ilele()
A = [];G = defaultdict(list);D = []
for i in range(m):
    a,b = ilele()
    G[a].append(b)
    G[b].append(a)
    D.append(a);D.append(b)
    A.append((a,b))
C = Counter(D)
g = C.most_common(1)[0][1]
if g == m:
    print("star topology")
else:
    f=0;c=0
    for i,j in G.items():
        if len(j) > 2:
            f=1
            break
        elif len(j) == 1:
            c+=1
    if f==1:
        print("unknown topology")
    else:
        if c == 2:
            print("bus topology")
        elif c == 0:
            print("ring topology")
        else:
            print("unknown topology")


import math
import sys
from collections import defaultdict
from collections import Counter
from collections import deque
import bisect
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda: map(int,input().split())
alele = lambda: list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
INF = 10 ** 18
MOD = 10 ** 9 + 7

n,m = ilele()
A = [];G = defaultdict(list)
for i in range(m):
    a,b = ilele()
    G[a].append(b)
    G[b].append(a)
    A.append((a,b))
C = set();f=0
for i,j in A:
    C.add(i)
if len(C) == 1:
    print("star topology")
else:
    f=0;c=0
    for i,j in G.items():
        if len(j) > 2:
            f=1
            break
        elif len(j) == 1:
            c+=1
    if f==1:
        print("unknown topology")
    else:
        if c == 2:
            print("bus topology")
        elif c == 0:
            print("ring topology")
        else:
            print("unknown topology")


import math
import sys
from collections import defaultdict
from collections import Counter
from collections import deque
import bisect
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda: map(int,input().split())
alele = lambda: list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
INF = 10 ** 18
MOD = 10 ** 9 + 7

n,m = ilele()
A = [];G = defaultdict(list)
for i in range(m):
    a,b = ilele()
    G[a].append(b)
    G[b].append(a)
    A.append((a,b))
C =set();f=0;tt = 0
for i,j in A:
    if len(C) == 0:
        C.add(min(i,j))
        tt = min(i,j)
    else:
        if i == tt:
            C.add(i)
        else:
            C.add(j)
if len(C) == 1:
    print("star topology")
else:
    f=0;c=0
    for i,j in G.items():
        if len(j) > 2:
            f=1
            break
        elif len(j) == 1:
            c+=1
    if f==1:
        print("unknown topology")
    else:
        if c == 2:
            print("bus topology")
        elif c == 0:
            print("ring topology")
        else:
            print("unknown topology")


import sys
from collections import defaultdict
mod = 1000000007
def get_array(): return list(map(int, sys.stdin.readline().split()))
def get_ints(): return map(int, sys.stdin.readline().split())
def input(): return sys.stdin.readline()
def print_array(a): print(" ".join(map(str, a)))
class Graph:
    def __init__(self): self.graph = defaultdict(list)
    def addWire(self, u, v):
        self.graph[u].append(v)
        self.graph[v].append(u)
    def topology(self, n):
        conn = []
        for i in range(1, n + 1): conn.append(len(self.graph[i]))
        conn = list(set(conn))
        if len(conn) == 1 and conn[0] == 2: return "ring topology"
        if len(conn) == 2:
            if conn[0] == 1 and conn[1] == n - 1: return "star topology"
            return "bus topology"
        return "unknown topology"
def main():
    n, m = get_ints()
    Network = Graph()
    for _ in range(m):
        x, y = get_ints()
        Network.addWire(x, y)
    print(Network.topology(n))
if __name__ == "__main__":
    main()


import sys
from collections import defaultdict
mod = 1000000007
def get_array(): return list(map(int, sys.stdin.readline().split()))
def get_ints(): return map(int, sys.stdin.readline().split())
def input(): return sys.stdin.readline()
def print_array(a): print(" ".join(map(str, a)))
class Graph:
    def __init__(self): self.graph = defaultdict(list)
    def addWire(self, u, v):
        self.graph[u].append(v)
        self.graph[v].append(u)
    def topology(self, n):
        conn = []
        for i in range(1, n + 1): conn.append(len(self.graph[i]))
        conn = list(set(conn))
        if len(conn) == 1 and conn[0] == 2: return "ring topology"
        if len(conn) == 2:
            if conn[0] == 1 and conn[1] == n - 1: return "star topology"
            if conn[0] == 1 and conn[1] == 2: return "bus topology"
        return "unknown topology"
def main():
    n, m = get_ints()
    Network = Graph()
    for _ in range(m):
        x, y = get_ints()
        Network.addWire(x, y)
    print(Network.topology(n))
if __name__ == "__main__":
    main()


bt="bus topology"
st="star topology"
rt="ring topology"
ut="unknown topology"
def main():
    n,m=map(int,input().split())
    G=[ [ 0 for j in range(n)] for i in range(n) ];
    s=0;
    S=[]
    for _ in range(m):
        x,y=map(int,input().split())
        G[x-1][y-1]=1
    for i in  range(n):
      for j in  range(n):
          s+=G[i][j]
      for j in  range(n):
          s+=G[j][i]
      S.append(s)
      s=0
    if S.count(2)==len(S):
        print (rt)
    elif S.count(2)==len(S)-2 and S.count(1)==2:
        print(bt)
    elif (S.count(n-1)==1 and S.count(1)==len(S)-1):
        print(st)
    else:
        print(ut)
main()


bt="bus topology"
st="star topology"
rt="ring topology"
ut="unknown topology"
def main():
    n,m=map(int,input().split())
    S=[ 0 for j in range(n)];
    for _ in range(m):
        x,y=map(int,input().split())
        S[x-1]+=1
        S[y-1]+=1
    if S.count(2)==len(S):
        print (rt)
        return
    elif S.count(2)==len(S)-2 and S.count(1)==2:
        print(bt)
        return
    elif (S.count(n-1)==1 and S.count(1)==len(S)-1):
        print(st)
        return
    else:
        print(ut)
        return
main()


# 292B

__author__ = 'artyom'

read = lambda: map(int, input().split())
n, m = read()
graph = [set() for _ in range(1 + n)]
degrees = [0] * (n + 1)
for __ in range(m):
  u, v = read()
  graph[u].add(v)
  graph[v].add(u)
  degrees[u] += 1
  degrees[v] += 1

def dfs(start):
  stack = [(start, None)]
  visited = [0] * (n + 1)
  while stack:
    v, parent = stack.pop()
    if degrees[v] > 2:
      return 'star' if all([degrees[u] == 1 for u in graph[v]]) else 'unknown'
    for u in graph[v]:
      if u != parent:
        if visited[u]:
          return 'ring' if u == start else 'unknown'
        stack.append((u, v))
    visited[v] = 1
  return 'bus'

print(dfs(1) + ' topology')


n,m = map(int,input().split())
adj = dict()

for i in range(m):
	u,v = map(int,input().split())

	if u not in adj:
		adj[u] = set()

	if v not in adj:
		adj[v] = set()

	adj[u].add(v)
	adj[v].add(u)

mark = [0]*(n+1)
mark[0] = 1
start = 1
topology = 'unknown'

one = 0
two = 0
em = 0
oth = 0

for k,v in adj.items():
	if len(v) == 1:
		one+=1
	elif len(v) == 2:
		two+=1
	elif len(v) == m:
		em+=1
	else:
		oth+=1

'''
bus: 2 have 1, n-2 have 2
ring: all have 2
star: 1 node has m, all others have 1
'''

if one == 2 and two == n-2:
	topology = 'bus'
elif two == n:
	topology = 'ring'
elif em == 1 and n-1 == one:
	topology = 'star'

print(topology+ " topology")


def main():
    n, m = map(int, input().split())
    g = [[] for _ in range(n + 1)]
    for _ in range(m):
        x, y = map(int, input().split())
        g[x].append(y)
        g[y].append(x)
    l = [True] * (n + 1)
    if n not in (m, m + 1):
        print("unknown topology")
        return

    def dfs(v):
        l[v] = False
        for u in g[v]:
            if l[u]:
                dfs(u)

    dfs(1)
    if l.count(True) > 1:
        print("unknown topology")
        return
    l = list(map(len, g))
    c2 = l.count(2)
    if m == n == c2:
        print("ring topology")
        return
    if m == n - 1:
        c1 = l.count(1)
        if c1 == 2 and c2 == n - 2:
            print("bus topology")
            return
        if c1 == m and m in l:
            print("star topology")
            return
    print("unknown topology")

if __name__ == '__main__':
    main()


def main():
    from sys import setrecursionlimit
    n, m = map(int, input().split())
    if n not in (m, m + 1):
        print("unknown topology")
        return
    setrecursionlimit(n + 500)
    g = [[] for _ in range(n + 1)]
    for _ in range(m):
        x, y = map(int, input().split())
        g[x].append(y)
        g[y].append(x)
    l = [True] * (n + 1)

    def dfs(v):
        l[v] = False
        for u in g[v]:
            if l[u]:
                dfs(u)

    dfs(1)
    if l.count(True) > 1:
        print("unknown topology")
        return
    l = list(map(len, g))
    c2 = l.count(2)
    if m == n == c2:
        print("ring topology")
        return
    if m == n - 1:
        c1 = l.count(1)
        if c1 == 2 and c2 == n - 2:
            print("bus topology")
            return
        if c1 == m and m in l:
            print("star topology")
            return
    print("unknown topology")

if __name__ == '__main__':
    main()


def main():
    from sys import setrecursionlimit
    n, m = map(int, input().split())
    if n not in (m, m + 1):
        print("unknown topology")
        return
    setrecursionlimit(n + 100)
    g = [[] for _ in range(n + 1)]
    for _ in range(m):
        x, y = map(int, input().split())
        g[x].append(y)
        g[y].append(x)
    l = [True] * (n + 1)

    def dfs(v):
        l[v] = False
        for u in g[v]:
            if l[u]:
                dfs(u)

    dfs(1)
    if l.count(True) > 1:
        print("unknown topology")
        return
    l = list(map(len, g))
    c2 = l.count(2)
    if m == n == c2:
        print("ring topology")
        return
    if m == n - 1:
        c1 = l.count(1)
        if c1 == 2 and c2 == n - 2:
            print("bus topology")
            return
        if c1 == m and m in l:
            print("star topology")
            return
    print("unknown topology")

if __name__ == '__main__':
    main()


def solve():
    n, m = map(int, input().split())
    if n not in (m, m + 1):
        return 3
    l = [0] * (n + 1)
    for _ in range(m):
        x, y = map(int, input().split())
        l[x] += 1
        l[y] += 1
    c2 = l.count(2)
    if m == n == c2:
        return 1
    if m == n - 1:
        c1 = l.count(1)
        if c1 == 2 and c2 == n - 2:
            return 0
        if c1 == m and m in l:
            return 2
    return 3

def main():
    print(("bus", "ring", "star", "unknown")[solve()], "topology")

if __name__ == '__main__':
    main()


def main():
    from sys import setrecursionlimit
    n, m = map(int, input().split())
    if n not in (m, m + 1):
        print("unknown topology")
        return
    setrecursionlimit(n + 5000)
    g = [[] for _ in range(n + 1)]
    for _ in range(m):
        x, y = map(int, input().split())
        g[x].append(y)
        g[y].append(x)
    l = [True] * (n + 1)

    def dfs(v):
        l[v] = False
        for u in g[v]:
            if l[u]:
                dfs(u)

    dfs(1)
    if l.count(True) > 1:
        print("unknown topology")
        return
    l = list(map(len, g))
    c2 = l.count(2)
    if m == n == c2:
        print("ring topology")
        return
    if m == n - 1:
        c1 = l.count(1)
        if c1 == 2 and c2 == n - 2:
            print("bus topology")
            return
        if c1 == m and m in l:
            print("star topology")
            return
    print("unknown topology")

if __name__ == '__main__':
    main()


from array import array
from collections import Counter

n, m = map(int, input().split())

a = array('L')

a.extend((0 for i in range(n)))

for i in range(m):
	x, y = map(int, input().split())
	a[x-1] += 1
	a[y-1] += 1

ca = array('L')
ca.extend((0 for i in range(max(a)+1)))

for i in a:
	ca[i] += 1

def c(i):
	if i >= len(ca) or i < 0:
		return 0
	else:
		return ca[i]

if c(1) == 2 and c(2) == n-2:
	print("bus topology")
elif c(2) == n:
	print("ring topology")
elif c(1) == n-1 and c(n-1) == 1:
	print("star topology")
else:
	print("unknown topology")


from array import array
from collections import Counter

n, m = map(int, input().split())

a = array('H')

a.extend((0 for i in range(n)))

for i in range(m):
	x, y = map(int, input().split())
	a[x-1] += 1
	a[y-1] += 1

c = Counter(a)

#print(c)

if c[1] == 2 and c[2] == n-2:
	print("bus topology")
elif c[2] == n:
	print("ring topology")
elif c[1] == n-1 and c[n-1] == 1:
	print("star topology")
else:
	print("unknown topology")


from array import array
from collections import Counter

n, m = map(int, input().split())

a = array('H')

a.extend((0 for i in range(n)))

for i in range(m):
	x, y = map(int, input().split())
	a[x-1] += 1
	a[y-1] += 1

ca = array('H')
ca.extend((0 for i in range(max(a)+1)))

for i in a:
	ca[i] += 1

def c(i):
	if i >= len(ca) or i < 0:
		return 0
	else:
		return ca[i]

if c(1) == 2 and c(2) == n-2:
	print("bus topology")
elif c(2) == n:
	print("ring topology")
elif c(1) == n-1 and c(n-1) == 1:
	print("star topology")
else:
	print("unknown topology")


n,m=map(int,input().split())
d={i:[] for i in range(1,n+1)}
for _ in range(m):
    a,b=map(int,input().split())
    d[a].append(b)
    d[b].append(a)
c=0
one,two=0,0
star=0
for i in d:
    if len(d[i])==1:
        c+=1
        one+=1
    elif len(d[i])==2:
        two+=1
    elif len(d[i])==n-1:
        star+=1

if c==(n-1) and star==1:
    print('star topology')

elif one==2 and  two==(n-2):
    print('bus topology')

elif two==n:
    print('ring topology')
else:
    print('unknown topology')


m, n = [int(i) for i in input().split()]
print(m, n)
adj = []
for i in range(m):
    adj.append([])
print(adj)
for i in range(n):
    first, second = [int(i) for i in input().split()]
    adj[first-1].append(second)
    adj[second-1].append(first)
print(adj)
if m <= 2:
    print("bus topology")
else:
    vertices = m
    edges = n
    ones = 0
    twos = 0
    if edges == vertices:
        for i in range(m):
            if len(adj[i]) == 1:
                ones += 1
            elif len(adj[i]) == 2:
                twos += 1
        if twos == m:
            print("ring topology")
        else:
            print("unknown topology")
    elif edges < vertices:
        for i in range(m):
            if len(adj[i]) == 1:
                ones += 1
            elif len(adj[i]) == 2:
                twos += 1
        print(ones, twos)
        if twos == m-2 and ones == 2:
            print("bus topology")
        elif ones == n:
            print("star topology")
        else:
            print("unknown topology")
    else:
        print("unknown topology")


m, n = [int(i) for i in input().split()]
adj = []
for i in range(m):
    adj.append([])
for i in range(n):
    first, second = [int(i) for i in input().split()]
    adj[first-1].append(second)
    adj[second-1].append(first)
if m <= 2:
    print("bus topology")
else:
    vertices = m
    edges = n
    ones = 0
    twos = 0
    if edges == vertices:
        for i in range(m):
            if len(adj[i]) == 1:
                ones += 1
            elif len(adj[i]) == 2:
                twos += 1
        if twos == m:
            print("ring topology")
        else:
            print("unknown topology")
    elif edges < vertices:
        for i in range(m):
            if len(adj[i]) == 1:
                ones += 1
            elif len(adj[i]) == 2:
                twos += 1
        print(ones, twos)
        if twos == m-2 and ones == 2:
            print("bus topology")
        elif ones == n:
            print("star topology")
        else:
            print("unknown topology")
    else:
        print("unknown topology")


m, n = [int(i) for i in input().split()]
adj = []
for i in range(m):
    adj.append([])
for i in range(n):
    first, second = [int(i) for i in input().split()]
    adj[first-1].append(second)
    adj[second-1].append(first)
if m <= 2:
    print("bus topology")
else:
    vertices = m
    edges = n
    ones = 0
    twos = 0
    if edges == vertices:
        for i in range(m):
            if len(adj[i]) == 1:
                ones += 1
            elif len(adj[i]) == 2:
                twos += 1
        if twos == m:
            print("ring topology")
        else:
            print("unknown topology")
    elif edges < vertices:
        every = 0
        for i in range(m):
            if len(adj[i]) == 1:
                ones += 1
            elif len(adj[i]) == 2:
                twos += 1
            elif len(adj[i]) == n:
                every += 1
        print(ones, twos)
        if twos == m-2 and ones == 2:
            print("bus topology")
        elif ones == n and every == 1:
            print("star topology")
        else:
            print("unknown topology")
    else:
        print("unknown topology")


m, n = [int(i) for i in input().split()]
print(m, n)
adj = []
for i in range(m):
    adj.append([])
print(adj)
for i in range(n):
    first, second = [int(i) for i in input().split()]
    adj[first-1].append(second)
    adj[second-1].append(first)
print(adj)
if m <= 2:
    print("bus topology")
else:
    vertices = m
    edges = n
    ones = 0
    twos = 0
    if edges == vertices:
        print("hi")
        for i in range(m):
            if len(adj[i]) == 1:
                ones += 1
            elif len(adj[i]) == 2:
                twos += 1
        if twos == m:
            print("ring topology")
        else:
            print("unknown topology")
    elif edges < vertices:
        print("hi2")
        for i in range(m):
            if len(adj[i]) == 1:
                ones += 1
            elif len(adj[i]) == 2:
                twos += 1
        print(ones, twos)
        if twos == m-2 and ones == 2:
            print("bus topology")
        elif ones == n:
            print("star topology")
        else:
            print("unknown topology")
    else:
        print("hi3")
        print("unknown topology")


m, n = [int(i) for i in input().split()]
adj = []
for i in range(m):
    adj.append([])
for i in range(n):
    first, second = [int(i) for i in input().split()]
    adj[first-1].append(second)
    adj[second-1].append(first)

vertices = m
edges = n
ones = 0
twos = 0
every = 0
if edges == vertices:
    for i in range(m):
        if len(adj[i]) == 1:
            ones += 1
        elif len(adj[i]) == 2:
            twos += 1
elif edges < vertices:
    for i in range(m):
        if len(adj[i]) == 1:
            ones += 1
        elif len(adj[i]) == 2:
            twos += 1
        elif len(adj[i]) == n:
            every += 1
if twos == m:
    print("ring topology")
elif ones == n and every == 1:
    print("star topology")
elif twos == m - 2 and ones == 2:
    print("bus topology")
else:
    print("unknown topology")


class List
  attr_accessor :element, :next_elem

  def initialize(element, next_elem)
    @element = element
    @next_elem = next_elem
  end
end

class Graph
  attr_accessor :vertices

  def initialize(vertices)
    @vertices = vertices
  end

  def add_edge(number1, number2)
    if vertices[number1].nil? then
      vertices[number1] = List.new(number2, nil)
    else
      vertices[number1] = List.new(number2, vertices[number1])
    end
  end

  def print_edges
    vertices.each_with_index do |vertex, index|
      # next if vertex == ""
      while !vertex.nil? do
        puts "edge #{index} - #{vertex.element}"
        vertex = vertex.next_elem
      end
    end
  end

end

network = Graph.new([])
n, m = gets.strip.split(" ").map(&:to_i)
number_of_connected_vertices = Array.new(n, 0)
m.times do
  vertex1, vertex2 = gets.strip.split(" ").map{|num| num.to_i - 1}
  network.add_edge(vertex1, vertex2)
  network.add_edge(vertex2, vertex1)
  number_of_connected_vertices[vertex2] += 1
  number_of_connected_vertices[vertex1] += 1
end
results = number_of_connected_vertices.group_by{|i| i}
if results[n - 1] && results[n - 1].count == 1 &&
   results[1] && results[1].count == n - 1
   answer = 'star topology'
elsif results[1] && results[1].count == 2 &&
  results[2] && results[2].count == n - 2
  answer = 'bus topology'
elsif results[2] &&  results[2].count == n
  answer = 'ring topology'
else
  answer = 'unknown topology'
end
puts answer


n, m = gets.split.map(&:to_i)

edges = m.times.map{ gets.split.map(&:to_i) }
v = n.times.map{ 0 }

if m == n
  edges.each do |e|
    v[e[0] - 1] += 1
    v[e[1] - 1] += 1
    if v[e[1] - 1] > 2 || v[e[0] - 1] >2
      puts 'unknown topology'
      exit
    end
  end
  puts 'ring topology'
  exit
elsif m + 1 == n
  edges.each do |e|
    v[e[0] - 1] += 1
    v[e[1] - 1] += 1
  end
  v.sort!
  if v[0] == 1 && v[1] == 1 && v[2] == 2
    puts 'bus topology'
    exit
  elsif v[-1] == m
    puts 'star topology'
    exit
  end
end

puts 'unknown topology'


input = gets.chomp.split(" ")
n = input[0].to_i
m = input[1].to_i

v1s = []
v2s = []

count_arr = []

edges = []

twos = 0
nontwos = 0

m.times do |i|
  input = gets.chomp.split(" ")

  v1 = input[0].to_i
  v2 = input[1].to_i

  v1s << v1
  v2s << v2

  count_arr[v1] ||= 0
  count_arr[v2] ||= 0

  count_arr[v1] += 1
  count_arr[v2] += 1

  if count_arr[v1] == m || count_arr[v2] == m
    puts "star topology"
    abort
  end
  edges << i
end

count_arr.compact!

count_arr.each do |el|
  if el == 2
    twos += 1
  else
    nontwos += 1
  end
end

if (twos == count_arr.size - 2) && (nontwos == 2)
  puts "bus topology"
  abort
end

if n == m
  puts "ring topology"
  abort
end

puts "unknown topology"


begin
  input = gets.chomp.split(" ")
  n = input[0].to_i
  m = input[1].to_i

  v1s = []
  v2s = []

  count_arr = []

  edges = []

  twos = 0
  nontwos = 0

  m.times do |i|
    input = gets.chomp.split(" ")

    v1 = input[0].to_i
    v2 = input[1].to_i

    v1s << v1
    v2s << v2

    count_arr[v1] ||= 0
    count_arr[v2] ||= 0

    count_arr[v1] += 1
    count_arr[v2] += 1

    if count_arr[v1] == m || count_arr[v2] == m
      puts "star topology"
      abort
    end
    edges << i
  end

  count_arr.compact!

  count_arr.each do |el|
    if el == 2
      twos += 1
    else
      if el > 2
        puts "unknown topology"
        abort
      else
        nontwos += 1
      end
    end
  end

  if (twos == count_arr.size - 2) && (nontwos == 2)
    puts "bus topology"
    abort
  end

  if n == m
    puts "ring topology"
    abort
  end

  puts "unknown topology"
rescue Exception
end


at_exit do
  vertex_count, edge_count = get_numbers_from_line[0..1]
  linked_count = [0]*vertex_count
  edge_count.times do
    x,y = get_numbers_from_line[0..1]
    linked_count[x-1] += 1
    linked_count[y-1] += 1
  end

  counts = {}
  linked_count.each do |count|
    counts[count] ||= 0
    counts[count] += 1
  end
  one_count = counts[1] || 0
  two_count = counts[2] || 0

  if one_count == 2 && two_count == vertex_count - 2 && edge_count == vertex_count-1
    puts 'bus topology'
  elsif one_count == 0 && two_count == vertex_count && edge_count == vertex_count
    puts 'ring topology'
  elsif one_count == vertex_count-1 && counts[vertex_count-1] == 1 && edge_count == vertex_count - 1
    puts 'star topology'
  else
    puts 'unknown topology'
  end

end

def get_numbers_from_line
  gets.strip.split.map(&:to_i)
end


__author__ = 'KestL'
n, m = [int(x) for x in raw_input().split()]
v = []
for i in range(n):
    v.append(0)
for i in range(m):
    x, y = [int(x) for x in raw_input().split()]
    v[x-1] +=1
    v[y-1] +=1
v = sorted(v, reverse=True)
if v[0] == n-1 and sum(v[1:]) == n-1:
    print "star topology"
else:
    kol2 = 0
    for vv in v:
        if vv == 2:
            kol2 += 1
    if kol2 == n - 2 and v[-1] == 1 and v[-2] == 1:
        print "bus topology"
    elif kol2 == n:
        print "ring topology"
    else:
        print "unknown topology"


def define_topology(graph, m):
    # Find nodes with single neighbour
    n = len(graph)
    if m == n:
        # Either ring or unknown
        if powers == n * [2]:
            return 'ring topology'
        else:
            return 'unknown topology'
    elif m == n - 1:
        if sorted(powers) == (n - 1) * [1] + [n-1]:
            return 'star topology'
        if sorted(powers) == [1, 1] + (n - 2) * [2]:
            return 'bus topology'
        else:
            return 'unknown topology'
    else:
        return 'unknown topology'

n, m = map(int, raw_input().split(' '))
graph = [[] for _ in range(n)]
powers = n * [0]
for _ in range(m):
    node1, node2 = map(int, raw_input().split(' '))
    node1 -= 1
    node2 -= 1
    powers[node1] += 1
    powers[node2] += 1
    graph[node1].append(node2)
    graph[node2].append(node1)

if m > n:
    print 'unknown topology'
else:
    print define_topology(graph, m)


I=lambda:map(int,raw_input().split())
n,m=I()
a=[0]*n
for _ in[0]*m:x,y=I();a[x-1]+=1;a[y-1]+=1
r="unknown"
s=set(a)
if s=={2}:r="ring"
if s=={1,2}:r="bus"
if s=={1,m}:r="star"
print r,"topology"