#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <algorithm>

#define FOR(i,a,n) for(int i=a; i<=n; i++)
#define REP(i,n) for(int i=0; i<n; i++)
#define PB push_back
#define MP make_pair
#define ALL(v) v.begin(),v.end()
#define xx first
#define yy second

using namespace std;

const int R = 2005;

vector<int> graf[R];
vector<int> las[R];
int low[R];
int pre[R];
int skladowa[R];
bool bylo[R];

int n, pre_cnt, numer_s;

void dfs_low(int v, int w){

    pre[v] = pre_cnt ++;
    bylo[v] = true;
    low[v] = pre[v];
    REP(i, graf[v].size()){
        int t = graf[v][i];
        if(t != w){
            if(bylo[t])
                low[v] = min(low[v], pre[t]);
            else{
                dfs_low(t, v);
                low[v] = min(low[v], low[t]);
            }
        }
    }
}

void policz_low(){

    FOR(i, 1, n)
        bylo[i] = false;

    pre_cnt = 1;
    numer_s = 0;
    FOR(i, 1, n)
        if(!bylo[i]){
            numer_s ++;
            dfs_low(i, -1);
        }
}

void dfs_skladowe(int v, int nr){
    skladowa[v] = nr;
    bylo[v] = true;
    REP(i, graf[v].size()){
        int t = graf[v][i];
        if(!bylo[t]){
            // Jeśli krawędź jest mostem
            if (low[t] == pre[t]){
                numer_s ++;
                dfs_skladowe(t, numer_s);
            }
            else
                dfs_skladowe(t, nr);
        }
    }
}

/* Liczy dwuspójne składowe */
void policz_skladowe(){

    policz_low();
    FOR(i, 1, n)
        bylo[i] = false;

    numer_s = 0;
    FOR(i, 1, n)
        if(!bylo[i]){
            numer_s ++;
            dfs_skladowe(i, numer_s);
        }

    // Ustawiamy krawędzie w drzewach
    FOR(v, 1, n)
        REP(j, graf[v].size()){
            int sw = skladowa[graf[v][j]];
            int sv = skladowa[v];
            if (sw != sv)
                las[sw].PB(sv);
        }
}

/* Wczytuje graf */
void read(){
    int m, a, b;
    scanf("%d %d", &n, &m);
    REP(i, m){
        scanf("%d %d", &a, &b);
        graf[a].PB(b);
        graf[b].PB(a);
    }
}

// Tablica dla dynamika
// 0 - najlepsza ścieżka z wierzchołka
// 1 - najlepsza ścieżka w podrzewie
int d[2][R];

void relax(int &a1, int &a2, int b){
    if (b >= a1){
        a2 = a1;
        a1 = b;
    }
    else if (b >= a2){
        a2 = b;
    }
}

void dfs_d(int v){
    bylo[v] = 1;
    int liczba_synow = 0;
    REP(i, las[v].size())
        if(!bylo[las[v][i]])
            liczba_synow ++;

    //printf("%d: lsynow: %d\n",v, liczba_synow);

    d[0][v] = liczba_synow + 1;
    d[1][v] = d[0][v];
    //printf("%d: 0: %d 1: %d\n",v, d[0][v], d[1][v]);

    int a1 = 0, a2 = 0;
    REP(i, las[v].size())
        if(!bylo[las[v][i]]){
            int w = las[v][i];
            dfs_d(w);
            relax(a1, a2, d[0][w]);
            d[0][v] = max(d[0][v], d[0][w] + liczba_synow);
            d[1][v] = max(d[1][v], d[1][w]);
        }
    //printf("%d: 0: %d 1: %d\n",v, d[0][v], d[1][v]);

    // jeśli ma więcej niż dwóch synow to dorzucamy najlepszą ścieżkę przez v
    if(liczba_synow >= 2)
        d[1][v] = max(d[1][v], a1 + a2 + (int)las[v].size() - 1);

    // dorzucamy ścieżkę od v (musimy też uwzględnić ojca jeśli istnieje)
    d[1][v] = max(d[1][v], d[0][v] + (int)las[v].size() - liczba_synow);
    //printf("%d: 0: %d 1: %d\n",v, d[0][v], d[1][v]);
}

int policz_d(){

    int sum = 1;
    FOR(i, 1, numer_s)
        bylo[i] = false;

    //printf("numer_s: %d\n", numer_s);
    FOR(i, 1, numer_s)
        if(!bylo[i]){
            dfs_d(i);
            sum += d[1][i] - 1;
            //printf("i: %d d[1][i]: %d\n", i, d[1][i]);
        }

    return n - sum;
}

void solve(){
    read();
    policz_skladowe();
    printf("%d\n", policz_d());
}

int main(){
    solve();
    return 0;
}


#include <cstdlib>
#include<iostream>
#include<vector>
#include<string.h>
#include<stdio.h>
using namespace std;
const int maxn=10000;
const int maxm=300000;
struct Edge{
    int st,ed;
    int next;
}edge[maxm];
int head[maxn];
int E;
int n,m;
int belong[maxn];
int bcnt;
int low[maxn];
int dfn[maxn];
int vis[maxn];
int stk[maxn];
int top;
int Index;
vector<int >tree[maxn];

void Addedge(int st,int ed){
    edge[E].st=st; edge[E].ed=ed; edge[E].next=head[st];head[st]=E++;
    edge[E].st=ed; edge[E].ed=st; edge[E].next=head[ed];head[ed]=E++;
}

void cutedge(int x,int pre){
    vis[x]=1;
    low[x]=dfn[x]=++Index;
    stk[++top]=x;
    for(int i=head[x];i!=-1;i=edge[i].next){
        int ed=edge[i].ed;
        if(ed==pre)continue;
        if(!dfn[ed]){
            cutedge(ed,x);
            if(low[ed]<low[x])low[x]=low[ed];
            if(low[ed]>dfn[x]){
                ++bcnt;
                int j;
                do{
                    j=stk[top--];
                    belong[j]=bcnt;
                }while(j!=ed);
            }
        }
        else if(low[x]>dfn[ed])low[x]=dfn[ed];
    }
}
int max1[maxn];
int max2[maxn];
int deg[maxn];
int yezi;
int dfs(int x){
     vis[x]=1;
    int ad=0;
    int ret=0;
    if(deg[x]<=1)yezi++;
    else ad=1;
    for(int i=0;i<tree[x].size();i++){
        int ed=tree[x][i];
        if(vis[ed])continue;
        int zz=dfs(ed);
        if(zz>ret)ret=zz;
        if(max1[ed]>max1[x]){
            max2[x]=max1[x];
            max1[x]=max1[ed];
        }
        else if(max1[ed]>max2[x]){
            max2[x]=max1[ed];
        }
    }
    max1[x]+=ad;
    ret=max(ret,max1[x]+max2[x]);
    return ret;
}

int solve(){
    bcnt=-1;
    top=Index=0;
    memset(dfn,0,sizeof(dfn));
    memset(vis,0,sizeof(vis));
    for(int i=1;i<=n;i++){
        if(!dfn[i])cutedge(i,-1);
        bcnt++;
        while(top){
        int j=stk[top--];
        belong[j]=bcnt;
    }
    }
//    cout<<top<<endl;

//    cout<<" bcnt: "<<bcnt<<endl;
    for(int i=0;i<=bcnt;i++)tree[i].clear();
    memset(deg,0,sizeof(deg));
    for(int i=0;i<E;i++){
        int st=edge[i].st;
        int ed=edge[i].ed;
        if(belong[st]!=belong[ed]){
            tree[belong[st]].push_back(belong[ed]);
            deg[belong[st]]++;
        }
    }
    int ans=n;
    memset(vis,0,sizeof(vis));
    memset(max1,0,sizeof(max1));
    memset(max2,0,sizeof(max2));
    int z=0;
 //   for(int i=1;i<=n;i++)
  //      cout<<"i: "<<i<<"be:  "<<belong[i]<<endl;
    for(int i=0;i<=bcnt;i++){
        if(!vis[i]){
            yezi=0;
            int  q=dfs(i);
            ans-=yezi+q-1;
 //           cout<<yezi<<"  "<<q<<" "<<endl;
        }
    }
    cout<<ans-1<<endl;
}

int main(int argc, char** argv) {
    cin>>n>>m;
    memset(head,-1,sizeof(head));
    E=0;
    int a,b;
    for(int i=1;i<=m;i++){
        scanf("%d%d",&a,&b);
        Addedge(a,b);
    }
    solve();
    return 0;
}


#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
#define rep(x, n) for (int x = 1; x <= n; ++x)
#define zrp(x, n) for (int x = n; x; --x)
#define FOR(x, l, r) for (int x = l; x <= r; ++x)
#define foredge(i, x) for (int i = start[x]; i; i = e[i].l)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define abs(a) ((a) > 0 ? (a) : (-(a)))
typedef long long int64;
const int maxN = 2005;
const int maxM = 100005;
struct edge{int a, l;} e[maxM * 2], e2[maxM * 2];
int start[maxN], head[maxN], low[maxN], dfn[maxN], d[maxN];
int n, m, tot, w, p, c, t, ans, st[maxN], top, bl[maxN], der[maxN];
bool in[maxN], vis[maxN];

void add(int x, int y)
{
    e[++tot].l = start[x]; e[tot].a = y; start[x] = tot;
    e[++tot].l = start[y]; e[tot].a = x; start[y] = tot;
}

void tarjan(int x, int fa)
{
    dfn[x] = low[x] = ++w;
    in[x] = 1; st[++top] = x;
    foredge(i, x)
    {
        int y = e[i].a;
        if (y == fa) continue;
        if (!dfn[y]) tarjan(y, x);
        if (in[y]) low[x] = min(low[x], low[y]);
    }
    if (low[x] == dfn[x])
    {
        ++c;
        do
        {
            bl[st[top]] = c;
            in[st[top]] = 0;
            --top; ++ans;
        }while (st[top + 1] != x);
        --ans;
    }
}

void add2(int x, int y)
{
    der[x]++;// der[y]++;
    e2[++tot].l = head[x]; e2[tot].a = y; head[x] = tot;
    //e2[++tot].l = head[y]; e2[tot].a = x; head[y] = tot;
}

void init()
{
    int x, y;
    scanf("%d%d", &n, &m);
    rep(i, m)
    {
        scanf("%d%d", &x, &y);
        add(x, y);
    }
    rep(i, n) if (!dfn[i])
        tarjan(i, 0);

    tot = 0;
    rep(x, n) foredge(i, x) if (bl[x] != bl[e[i].a])
        add2(bl[x], bl[e[i].a]);
}

void dfs(int x, int fa)
{
    vis[x] = 1; ++t;
    if (d[x] > d[p]) p = x;
    for (int i = head[x]; i; i = e2[i].l)
        if (e2[i].a != fa)
        {
            d[e2[i].a] = d[x] + 1;
            dfs(e2[i].a, x);
        }
}

void make(int x)
{
    p = x; d[x] = 1; dfs(x, 0);
    x = p; d[x] = 1; t = 0; dfs(x, 0);
    ans = ans + t - d[p] + 3;
}

void work()
{
    rep(i, c) if (!vis[i])
        make(i);
    rep(i, c) if (der[i] == 1)
        --ans;
    --ans;
    printf("%d\n", ans);
}

int main()
{
    init();
    work();
    return 0;
}


#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
#define rep(x, n) for (int x = 1; x <= n; ++x)
#define zrp(x, n) for (int x = n; x; --x)
#define FOR(x, l, r) for (int x = l; x <= r; ++x)
#define foredge(i, x) for (int i = start[x]; i; i = e[i].l)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define abs(a) ((a) > 0 ? (a) : (-(a)))
typedef long long int64;
const int maxN = 2005;
const int maxM = 100005;
struct edge{int a, l;} e[maxM * 2], e2[maxM * 2];
int start[maxN], head[maxN], low[maxN], dfn[maxN], d[maxN];
int n, m, tot, w, p, c, t, ans, st[maxN], top, bl[maxN], der[maxN];
bool in[maxN], vis[maxN];

void add(int x, int y)
{
    e[++tot].l = start[x]; e[tot].a = y; start[x] = tot;
    e[++tot].l = start[y]; e[tot].a = x; start[y] = tot;
}

void tarjan(int x, int fa)
{
    dfn[x] = low[x] = ++w;
    in[x] = 1; st[++top] = x;
    foredge(i, x)
    {
        int y = e[i].a;
        if (y == fa) continue;
        if (!dfn[y]) tarjan(y, x);
        if (in[y]) low[x] = min(low[x], low[y]);
    }
    if (low[x] == dfn[x])
    {
        ++c;
        do
        {
            bl[st[top]] = c;
            in[st[top]] = 0;
            --top; ++ans;
        }while (st[top + 1] != x);
        --ans;
    }
}

void add2(int x, int y)
{
    der[x]++;// der[y]++;
    e2[++tot].l = head[x]; e2[tot].a = y; head[x] = tot;
    //e2[++tot].l = head[y]; e2[tot].a = x; head[y] = tot;
}

void init()
{
    int x, y;
    scanf("%d%d", &n, &m);
    rep(i, m)
    {
        scanf("%d%d", &x, &y);
        add(x, y);
    }
    rep(i, n) if (!dfn[i])
        tarjan(i, 0);

    tot = 0;
    rep(x, n) foredge(i, x) if (bl[x] != bl[e[i].a])
        add2(bl[x], bl[e[i].a]);
}

void dfs(int x, int fa)
{
    vis[x] = 1; ++t;
    if (d[x] > d[p]) p = x;
    for (int i = head[x]; i; i = e2[i].l)
        if (e2[i].a != fa)
        {
            d[e2[i].a] = d[x] + 1;
            dfs(e2[i].a, x);
        }
}

void make(int x)
{
    p = x; d[x] = 1; dfs(x, 0);
    x = p; d[x] = 1; t = 0; dfs(x, 0);
    if (t == 1) ++ans;
        else ans = ans + t - d[p] + 3;
}

void work()
{
    rep(i, c) if (!vis[i])
        make(i);
    rep(i, c) if (der[i] == 1)
        --ans;
    --ans;
    printf("%d\n", ans);
}

int main()
{
    init();
    work();
    return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

const int maxn  = 2000 + 10;
const int maxm = 100000 + 10;
const int inf = 1000000000;
int elist[maxm * 2][2],hd[maxn];
int trE[maxn * 2][2],htr[maxn];
int cnte;
int n,m,ans;

void addEdge(int list[][2],int hd[],int u,int v){
    list[cnte][0] = v;
    list[cnte][1] = hd[u];
    hd[u] = cnte;
    cnte++;
}

int dfn[maxn],low[maxn];
int tag,ps,sp,id[maxn],st[maxn];

void getComp(int u,int fa){
    dfn[u] = low[u] = ps++;
    st[sp++] = u;
    for(int j = hd[u];j!=-1;j = elist[j][1]){
        int v = elist[j][0];
        if(v==fa)continue;
        if(dfn[v]<0){
            getComp(v,u);
            low[u] = min(low[u],low[v]);
            if(dfn[u]<low[v]){
                do{
                    id[st[--sp]] = tag;
                }while(st[sp]!=v);
                tag++;
            }
        }else low[u] = min(dfn[v],low[u]);
    }
}

void makeTree(){
    tag = ps = 0;
    fill(dfn,dfn + n,-1);
    for(int i=0;i<n;i++)
        if(dfn[i]<0){
            sp = 0;
            getComp(i,-1);
            while(sp>0)id[st[--sp]] = tag;
            tag++;
        }
    fill(htr,htr + tag,-1);
    cnte = 0;
    for(int i=0;i<n;i++)
        for(int j = hd[i];j!=-1;j = elist[j][1]){
            int v = elist[j][0];
            if(id[i]!=id[v]){
                addEdge(trE,htr,id[i],id[v]);
            }
        }
    ans = n - tag;
    //cout<<tag<<endl;
}

int F[maxn][3],diff[maxn];
void dp(int u,int fa){
    //cout<<fa<<' '<<u<<endl;
    dfn[u] = 1;
    int ns = 0;
    F[u][0] = F[u][1] = F[u][2] = inf;
    diff[u] = 0;
    int minOver = inf,minPass = inf,eV[2],tV,d;
    for(int j = htr[u];j!=-1;j = trE[j][1]){
        int v = trE[j][0];
        if(v==fa)continue;
        dp(v,u);
        ns++;
        diff[u] += diff[v];
        tV = F[v][0] - diff[v];
        if(ns<=2)eV[ns - 1] = tV;
        else eV[1] = min(eV[1],tV);
        if(ns>1 && eV[0]>eV[1])swap(eV[0],eV[1]);
        minOver = min(minOver, F[v][2] - diff[v]);
        minPass = min(minPass,min(F[v][1],F[v][0]) - diff[v]);
    }
    if(ns>0){
        diff[u]++;
        F[u][0] = diff[u] + eV[0] - 1;
        F[u][2] = min(diff[u] + minOver,diff[u] + minPass) - (ns<2 && fa<0);

        if(ns>1)
            F[u][1] = diff[u] + eV[0] + eV[1] - 1;
    }else F[u][0] = 0;
}

void work(){
    n = tag;
    int nc = 0;
    fill(dfn,dfn + n,0);
    for(int i=0;i<n;i++)
        if(!dfn[i]){
            nc++;
            dp(i,-1);
            ans += min(F[i][0],min(F[i][1],F[i][2]));
        }
    /*for(int i=0;i<n;i++)
        printf("%d %d %d %d %d\n",i,F[i][0],F[i][1],F[i][2],diff[i]);*/
    ans += nc - 1;
    cout<<ans<<endl;
}

int main(){
    scanf("%d%d",&n,&m);
    int x,y;
    fill(hd,hd + n,-1);
    cnte = ans = 0;
    for(int i=0;i<m;i++){
        scanf("%d%d",&x,&y);
        x--,y--;
        addEdge(elist,hd,x,y);
        addEdge(elist,hd,y,x);
    }
    makeTree();
    work();
    return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

const int maxn  = 2000 + 10;
const int maxm = 100000 + 10;
const int inf = 1000000000;
int elist[maxm * 2][2],hd[maxn];
int trE[maxn * 2][2],htr[maxn];
int cnte;
int n,m,ans;

void addEdge(int list[][2],int hd[],int u,int v){
    list[cnte][0] = v;
    list[cnte][1] = hd[u];
    hd[u] = cnte;
    cnte++;
}

int dfn[maxn],low[maxn];
int tag,ps,sp,id[maxn],st[maxn];

void getComp(int u,int fa){
    dfn[u] = low[u] = ps++;
    st[sp++] = u;
    for(int j = hd[u];j!=-1;j = elist[j][1]){
        int v = elist[j][0];
        if(v==fa)continue;
        if(dfn[v]<0){
            getComp(v,u);
            low[u] = min(low[u],low[v]);
            if(dfn[u]<low[v]){
                do{
                    id[st[--sp]] = tag;
                }while(st[sp]!=v);
                tag++;
            }
        }else low[u] = min(dfn[v],low[u]);
    }
}

void makeTree(){
    tag = ps = 0;
    fill(dfn,dfn + n,-1);
    for(int i=0;i<n;i++)
        if(dfn[i]<0){
            sp = 0;
            getComp(i,-1);
            while(sp>0)id[st[--sp]] = tag;
            tag++;
        }
    fill(htr,htr + tag,-1);
    cnte = 0;
    for(int i=0;i<n;i++)
        for(int j = hd[i];j!=-1;j = elist[j][1]){
            int v = elist[j][0];
            if(id[i]!=id[v]){
                addEdge(trE,htr,id[i],id[v]);
            }
        }
    ans = n - tag;
}

int F[maxn][3],diff[maxn];
void dp(int u,int fa){
    //cout<<fa<<' '<<u<<endl;
    dfn[u] = 1;
    int ns = 0;
    F[u][0] = F[u][1] = F[u][2] = inf;
    diff[u] = 0;
    int minOver = inf,minPass = inf,eV[2],tV,d;
    for(int j = htr[u];j!=-1;j = trE[j][1]){
        int v = trE[j][0];
        if(v==fa)continue;
        dp(v,u);
        ns++;
        diff[u] += diff[v];
        tV = F[v][0] - diff[v];
        if(ns<=2)eV[ns - 1] = tV;
        else eV[1] = min(eV[1],tV);
        if(ns>1 && eV[0]>eV[1])swap(eV[0],eV[1]);
        minOver = min(minOver, F[v][2] - diff[v]);
        minPass = min(minPass,min(F[v][1],F[v][0]) - diff[v]);
    }
    if(ns>0){
        diff[u]++;
        F[u][0] = diff[u] + eV[0] - 1;
        F[u][2] = min(diff[u] + minOver,diff[u] + minPass - (ns==1));
        if(ns>1)
            F[u][1] = diff[u] + eV[0] + eV[1] - 1;
    }else F[u][0] = 0;
}

void work(){
    n = tag;
    int nc = 0;
    fill(dfn,dfn + n,0);
    for(int i=0;i<n;i++)
        if(!dfn[i]){
            nc++;
            dp(i,-1);
            ans += min(F[i][0],min(F[i][1],F[i][2]));
        }
    /*for(int i=0;i<n;i++)
        printf("%d %d %d %d %d\n",i,F[i][0],F[i][1],F[i][2],diff[i]);*/
    ans += nc - 1;
    cout<<ans<<endl;
}

int main(){
    scanf("%d%d",&n,&m);
    int x,y;
    fill(hd,hd + n,-1);
    cnte = ans = 0;
    for(int i=0;i<m;i++){
        scanf("%d%d",&x,&y);
        x--,y--;
        addEdge(elist,hd,x,y);
        addEdge(elist,hd,y,x);
    }
    makeTree();
    work();
    return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

const int maxn  = 2000 + 10;
const int maxm = 100000 + 10;
const int inf = 1000000000;
int elist[maxm * 2][2],hd[maxn];
int trE[maxn * 2][2],htr[maxn];
int cnte;
int n,m,ans;

void addEdge(int list[][2],int hd[],int u,int v){
    list[cnte][0] = v;
    list[cnte][1] = hd[u];
    hd[u] = cnte;
    cnte++;
}

int dfn[maxn],low[maxn];
int tag,ps,sp,id[maxn],st[maxn];

void getComp(int u,int fa){
    dfn[u] = low[u] = ps++;
    st[sp++] = u;
    for(int j = hd[u];j!=-1;j = elist[j][1]){
        int v = elist[j][0];
        if(v==fa)continue;
        if(dfn[v]<0){
            getComp(v,u);
            low[u] = min(low[u],low[v]);
            if(dfn[u]<low[v]){
                while(sp>0 && st[sp - 1]!=u)
                    id[st[--sp]] = tag;
                tag++;
            }
        }else low[u] = min(dfn[v],low[u]);
    }
}

void makeTree(){
    tag = ps = 0;
    fill(dfn,dfn + n,-1);
    for(int i=0;i<n;i++)
        if(dfn[i]<0){
            sp = 0;
            getComp(i,-1);
            while(sp>0)id[st[--sp]] = tag;
            tag++;
        }
    fill(htr,htr + tag,-1);
    cnte = 0;
    for(int i=0;i<n;i++)
        for(int j = hd[i];j!=-1;j = elist[j][1]){
            int v = elist[j][0];
            if(id[i]!=id[v])
                addEdge(trE,htr,id[i],id[v]);
        }
    ans = n - tag;
}

int F[maxn][3],diff[maxn];
void dp(int u,int fa){
    //cout<<fa<<' '<<u<<endl;
    dfn[u] = 1;
    int ns = 0;
    F[u][0] = F[u][1] = F[u][2] = inf;
    diff[u] = 0;
    int minOver = inf,minPass = inf,eV[2],tV,d;
    for(int j = htr[u];j!=-1;j = trE[j][1]){
        int v = trE[j][0];
        if(v==fa)continue;
        dp(v,u);
        ns++;
        diff[u] += diff[v];
        tV = F[v][0] - diff[v];
        if(ns<=2)eV[ns - 1] = tV;
        else eV[1] = min(eV[1],tV);
        if(ns>1 && eV[0]>eV[1])swap(eV[0],eV[1]);
        minOver = min(minOver, F[v][2] - diff[v]);
        minPass = min(minPass,min(F[v][1],F[v][0]) - diff[v]);
    }
    if(ns>0){
        diff[u]++;
        F[u][0] = diff[u] + eV[0] - 1;
        F[u][2] = min(diff[u] + minOver,diff[u] + minPass - (ns==1));
        if(ns>1)
            F[u][1] = diff[u] + eV[0] + eV[1] - 1;
    }else F[u][0] = 0;
}

void work(){
    n = tag;
    int nc = 0;
    fill(dfn,dfn + n,0);
    for(int i=0;i<n;i++)
        if(!dfn[i]){
            nc++;
            dp(i,-1);
            ans += min(F[i][0],min(F[i][1],F[i][2]));
        }
    /*for(int i=0;i<n;i++)
        printf("%d %d %d %d %d\n",i,F[i][0],F[i][1],F[i][2],diff[i]);*/
    ans += nc - 1;
    cout<<ans<<endl;
}

int main(){
    scanf("%d%d",&n,&m);
    int x,y;
    fill(hd,hd + n,-1);
    cnte = ans = 0;
    for(int i=0;i<m;i++){
        scanf("%d%d",&x,&y);
        x--,y--;
        addEdge(elist,hd,x,y);
        addEdge(elist,hd,y,x);
    }
    makeTree();
    work();
    return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

const int maxn  = 2000 + 10;
const int maxm = 100000 + 10;
const int inf = 1000000000;
int elist[maxm * 2][2],hd[maxn];
int trE[maxn * 2][2],htr[maxn];
int cnte;
int n,m,ans;

void addEdge(int list[][2],int hd[],int u,int v){
    list[cnte][0] = v;
    list[cnte][1] = hd[u];
    hd[u] = cnte;
    cnte++;
}

int dfn[maxn],low[maxn],;
int tag,ps,sp,id[maxn],st[maxn];

void getComp(int u,int fa){
    dfn[u] = low[u] = ps++;
    st[sp++] = u;
    for(int j = hd[u];j!=-1;j = elist[j][1]){
        int v = elist[j][0];
        if(v==fa)continue;
        if(dfn[v]<0){
            getComp(v,u);
            low[u] = min(low[u],low[v]);
            if(dfn[u]<low[v]){
                while(sp>0 && st[sp - 1]!=u)
                    id[st[--sp]] = tag;
                tag++;
            }
        }else low[u] = min(dfn[v],low[u]);
    }
}

void makeTree(){
    tag = ps = 0;
    fill(dfn,dfn + n,-1);
    for(int i=0;i<n;i++)
        if(dfn[i]<0){
            sp = 0;
            getComp(i,-1);
            while(sp>0)id[st[--sp]] = tag;
            tag++;
        }
    fill(htr,htr + tag,-1);
    cnte = 0;
    for(int i=0;i<n;i++)
        for(int j = hd[i];j!=-1;j = elist[j][1]){
            int v = elist[j][0];
            if(id[i]!=id[v])
                addEdge(trE,htr,id[i],id[v]);
        }
    ans = n - tag;
}

int F[maxn][3],diff[maxn];
void dp(int u,int fa){
    dfn[u] = 1;
    int ns = 0;
    F[u][0] = F[u][1] = F[u][2] = inf;
    diff[u] = 0;
    int minOver = inf,minPass = inf,eV[2],tV,d;
    for(int j = htr[u];j!=-1;j = trE[j][1]){
        int v = trE[j][0];
        if(v==fa)continue;
        dp(v,u);
        ns++;
        diff[u] += diff[v];
        tV = F[v][0] - diff[v];
        if(ns<=2)eV[ns - 1] = tV;
        else eV[0] = min(eV[0],tV);
        if(ns>1 && eV[0]<eV[1])swap(eV[0],eV[1]);
        minOver = min(minOver, F[v][2] - diff[v]);
        minPass = min(minPass,F[v][1] - diff[v]);
    }
    if(ns>0){
        diff[u]++;
        F[u][0] = diff[u] + eV[0] - 1;
        F[u][2] = min(diff[u] + minOver,diff[u] + minPass - (ns==1));
        if(ns>1)
            F[u][1] = diff[u] + eV[0] + eV[1] - 1;
    }else F[u][0] = 0;
}

void work(){
    n = tag;
    int nc = 0;
    fill(dfn,dfn + n,0);
    for(int i=0;i<n;i++)
        if(!dfn[i]){
            nc++;
            dp(i,-1);
            ans += min(F[i][0],min(F[i][1],F[i][2]));
        }
    /*for(int i=0;i<n;i++)
        printf("%d %d %d %d %d\n",i,F[i][0],F[i][1],F[i][2],diff[i]);*/
    ans += nc - 1;
    cout<<ans<<endl;
}

int main(){
    scanf("%d%d",&n,&m);
    int x,y;
    fill(hd,hd + n,-1);
    cnte = ans = 0;
    for(int i=0;i<m;i++){
        scanf("%d%d",&x,&y);
        x--,y--;
        addEdge(elist,hd,x,y);
        addEdge(elist,hd,y,x);
    }
    makeTree();
    work();
    return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

const int maxn  = 2000 + 10;
const int maxm = 100000 + 10;
const int inf = 1000000000;
int elist[maxm * 2][2],hd[maxn];
int trE[maxn * 2][2],htr[maxn];
int cnte;
int n,m,ans;

void addEdge(int list[][2],int hd[],int u,int v){
    list[cnte][0] = v;
    list[cnte][1] = hd[u];
    hd[u] = cnte;
    cnte++;
}

int dfn[maxn],low[maxn];
int tag,ps,sp,id[maxn],st[maxn];

void getComp(int u,int fa){
    dfn[u] = low[u] = ps++;
    st[sp++] = u;
    for(int j = hd[u];j!=-1;j = elist[j][1]){
        int v = elist[j][0];
        if(v==fa)continue;
        if(dfn[v]<0){
            getComp(v,u);
            low[u] = min(low[u],low[v]);
            if(dfn[u]<low[v]){
                while(sp>0 && st[sp - 1]!=u)
                    id[st[--sp]] = tag;
                tag++;
            }
        }else low[u] = min(dfn[v],low[u]);
    }
}

void makeTree(){
    tag = ps = 0;
    fill(dfn,dfn + n,-1);
    for(int i=0;i<n;i++)
        if(dfn[i]<0){
            sp = 0;
            getComp(i,-1);
            while(sp>0)id[st[--sp]] = tag;
            tag++;
        }
    fill(htr,htr + tag,-1);
    cnte = 0;
    for(int i=0;i<n;i++)
        for(int j = hd[i];j!=-1;j = elist[j][1]){
            int v = elist[j][0];
            if(id[i]!=id[v])
                addEdge(trE,htr,id[i],id[v]);
        }
    ans = n - tag;
}

int F[maxn][3],diff[maxn];
void dp(int u,int fa){
    dfn[u] = 1;
    int ns = 0;
    F[u][0] = F[u][1] = F[u][2] = inf;
    diff[u] = 0;
    int minOver = inf,minPass = inf,eV[2],tV,d;
    for(int j = htr[u];j!=-1;j = trE[j][1]){
        int v = trE[j][0];
        if(v==fa)continue;
        dp(v,u);
        ns++;
        diff[u] += diff[v];
        tV = F[v][0] - diff[v];
        if(ns<=2)eV[ns - 1] = tV;
        else eV[0] = min(eV[0],tV);
        if(ns>1 && eV[0]<eV[1])swap(eV[0],eV[1]);
        minOver = min(minOver, F[v][2] - diff[v]);
        minPass = min(minPass,F[v][1] - diff[v]);
    }
    if(ns>0){
        diff[u]++;
        F[u][0] = diff[u] + eV[0] - 1;
        F[u][2] = min(diff[u] + minOver,diff[u] + minPass - (ns==1));
        if(ns>1)
            F[u][1] = diff[u] + eV[0] + eV[1] - 1;
    }else F[u][0] = 0;
}

void work(){
    n = tag;
    int nc = 0;
    fill(dfn,dfn + n,0);
    for(int i=0;i<n;i++)
        if(!dfn[i]){
            nc++;
            dp(i,-1);
            ans += min(F[i][0],min(F[i][1],F[i][2]));
        }
    /*for(int i=0;i<n;i++)
        printf("%d %d %d %d %d\n",i,F[i][0],F[i][1],F[i][2],diff[i]);*/
    ans += nc - 1;
    cout<<ans<<endl;
}

int main(){
    scanf("%d%d",&n,&m);
    int x,y;
    fill(hd,hd + n,-1);
    cnte = ans = 0;
    for(int i=0;i<m;i++){
        scanf("%d%d",&x,&y);
        x--,y--;
        addEdge(elist,hd,x,y);
        addEdge(elist,hd,y,x);
    }
    makeTree();
    work();
    return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

const int maxn  = 2000 + 10;
const int maxm = 100000 + 10;
const int inf = 1000000000;
int elist[maxm * 2][2],hd[maxn];
int trE[maxn * 2][2],htr[maxn];
int cnte;
int n,m,ans;

void addEdge(int list[][2],int hd[],int u,int v){
    list[cnte][0] = v;
    list[cnte][1] = hd[u];
    hd[u] = cnte;
    cnte++;
}

int dfn[maxn],low[maxn];
int tag,ps,sp,id[maxn],st[maxn];

void getComp(int u,int fa){
    dfn[u] = low[u] = ps++;
    st[sp++] = u;
    for(int j = hd[u];j!=-1;j = elist[j][1]){
        int v = elist[j][0];
        if(v==fa)continue;
        if(dfn[v]<0){
            getComp(v,u);
            low[u] = min(low[u],low[v]);
            if(dfn[u]<low[v]){
                do{
                    id[st[--sp]] = tag;
                }while(st[sp]!=v);
                tag++;
            }
        }else low[u] = min(dfn[v],low[u]);
    }
}

void makeTree(){
    tag = ps = 0;
    fill(dfn,dfn + n,-1);
    for(int i=0;i<n;i++)
        if(dfn[i]<0){
            sp = 0;
            getComp(i,-1);
            while(sp>0)id[st[--sp]] = tag;
            tag++;
        }
    fill(htr,htr + tag,-1);
    cnte = 0;
    for(int i=0;i<n;i++)
        for(int j = hd[i];j!=-1;j = elist[j][1]){
            int v = elist[j][0];
            if(id[i]!=id[v]){
                addEdge(trE,htr,id[i],id[v]);
            }
        }
    ans = n - tag;
    //cout<<tag<<endl;
}

int F[maxn][3],diff[maxn];
void dp(int u,int fa){
    //cout<<fa<<' '<<u<<endl;
    dfn[u] = 1;
    int ns = 0;
    F[u][0] = F[u][1] = F[u][2] = inf;
    diff[u] = 0;
    int minOver = inf,minPass = inf,eV[2],tV,d;
    for(int j = htr[u];j!=-1;j = trE[j][1]){
        int v = trE[j][0];
        if(v==fa)continue;
        dp(v,u);
        ns++;
        diff[u] += diff[v];
        tV = F[v][0] - diff[v];
        if(ns<=2)eV[ns - 1] = tV;
        else eV[1] = min(eV[1],tV);
        if(ns>1 && eV[0]>eV[1])swap(eV[0],eV[1]);
        minOver = min(minOver, F[v][2] - diff[v]);
        minPass = min(minPass,min(F[v][1],F[v][0]) - diff[v]);
    }
    if(ns>0){
        diff[u]++;
        F[u][0] = diff[u] + eV[0] - 1;
        F[u][2] = min(diff[u] + minOver,diff[u] + minPass - (ns==1 && fa<0));
        if(ns>1)
            F[u][1] = diff[u] + eV[0] + eV[1] - 1;
    }else F[u][0] = 0;
}

void work(){
    n = tag;
    int nc = 0;
    fill(dfn,dfn + n,0);
    for(int i=0;i<n;i++)
        if(!dfn[i]){
            nc++;
            dp(i,-1);
            ans += min(F[i][0],min(F[i][1],F[i][2]));
        }
    /*for(int i=0;i<n;i++)
        printf("%d %d %d %d %d\n",i,F[i][0],F[i][1],F[i][2],diff[i]);*/
    ans += nc - 1;
    cout<<ans<<endl;
}

int main(){
    scanf("%d%d",&n,&m);
    int x,y;
    fill(hd,hd + n,-1);
    cnte = ans = 0;
    for(int i=0;i<m;i++){
        scanf("%d%d",&x,&y);
        x--,y--;
        addEdge(elist,hd,x,y);
        addEdge(elist,hd,y,x);
    }
    makeTree();
    work();
    return 0;
}


#include "bits/stdc++.h"

using namespace std;

#define LL long long

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, m;
    cin >> n >> m;

    int goalSum = n * (n + 1) / 2;

    deque<pair<int, int>> problemBank(n, make_pair(0, 0));

    int diff;

    for (int i = 0; i < m; i++)
    {
        cin >> diff;
        problemBank.at(diff - 1).second++;

        if (problemBank.at(diff - 1).first == 0)
        {
            problemBank.at(diff - 1).first = 1;
            problemBank.at(diff - 1).second--;
            goalSum -= diff;
        }

        // cout << "goal sum: " << goalSum << endl;

        if (goalSum == 0)
        {
            cout << 1;
            goalSum = n * (n + 1) / 2;

            for (int j = 0; j < n; j++)
            {
                problemBank.at(j).first = 0;
            }
        }
        else
            cout << 0;
    }

    return 0;
}


#include "bits/stdc++.h"

using namespace std;

#define LL long long

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    LL n, m;
    cin >> n >> m;

    LL goalSum = n * (n + 1) / 2;

    deque<pair<LL, LL>> problemBank(n, make_pair(0, 0));

    LL diff;

    for (int i = 0; i < m; i++)
    {
        cin >> diff;
        problemBank.at(diff - 1).second++;

        if (problemBank.at(diff - 1).first == 0)
        {
            problemBank.at(diff - 1).first = 1;
            problemBank.at(diff - 1).second--;
            goalSum -= diff;
        }

        // cout << "goal sum: " << goalSum << endl;

        if (goalSum == 0)
        {
            cout << 1;
            goalSum = n * (n + 1) / 2;

            for (int j = 0; j < n; j++)
            {
                problemBank.at(j).first = 0;

                if (problemBank.at(j).second > 0)
                {
                    goalSum -= j + 1;
                    problemBank.at(j).second--;
                    problemBank.at(j).first = 1;
                }
            }
        }
        else
            cout << 0;
    }

    return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

using namespace std;

int main(){
	int n, m;
	cin >> n >> m;
	vector<int> v(m);
	for (int i = 0; i < m; i++) {
		int t;
		cin >> t;
		v[i] = t;
	}

	int map_size = 0;
	map<int, bool> mepi;
	string res = "";
	for (int i = 0; i < m; i++) {
		int curr = v[i];
		// printf("%d\t%d\t%d\n", i, curr, map_size);
		if (mepi.find(curr) == mepi.end() && curr >= 1 && curr <= n) {
			map_size++;
			if (map_size >= n) {
				res = res + "1";
				mepi[curr] = true;
				mepi.clear();
				map_size = 0;
			} else {
				res = res + "0";
				mepi[curr] = false;
			}
		} else {
			if (mepi[curr]) {
				res = res + "1";
			} else {
				res = res + "0";
			}
		}
	}

	cout << res << endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>

using namespace std;

int main(){
	int n, m;
	cin >> n >> m;
	int a[100001];
	for (int i = 0; i < 100001; i++) {
		a[i] = 0;
	}
	vector<int> v(m);
	for (int i = 0; i < m; i++) {
		int t;
		cin >> t;
		v[i] = t;
	}
	string res = "";
	set<int> seti;
	for (int i = 0; i < m; i++) {
		int curr = v[i];
		a[curr]++;
		seti.insert(curr);

		if (seti.size() >= n) {
			res = res + "1";
			seti.clear();
			for (int j = 0; j < 100001; j++) {
				if (a[j] > 1) {
					a[j]--;
					seti.insert(j);
				} else {
					a[j] = 0;
				}
			}
		} else {
			res = res + "0";
		}
	}
	cout << res << endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	string ans = "";
	int cnt = 0;
	int sum = 0;
	map<int, int> M;
	for (int i = 0; i < m; i++){
		int x;
		cin >> x;
		M[x]++;
		if (M[x] == 1) sum++;
		if (sum == n) {
			ans += '1';
			for (int j = 1; j <= n; j++) {
				M[j]--;
				if (M[j] == 0) sum--;
			}
		} else {
		    ans += '0';
		}
	}
	cout << ans << endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>

using namespace std;

int main(){
	int n, m;
	cin >> n >> m;
	int a[100001];
	for (int i = 0; i < 100001; i++) {
		a[i] = 0;
	}
	// vector<int> v(m);
	// for (int i = 0; i < m; i++) {
	// 	int t;
	// 	cin >> t;
	// 	v[i] = t;
	// }
	string res = "";
	set<int> seti;
	for (int i = 0; i < m; i++) {
		int curr;
		cin >> curr;
		// int curr = v[i];
		a[curr]++;
		seti.insert(curr);

		if (seti.size() >= n) {
			res = res + "1";
			seti.clear();
			for (int j = 0; j < m + 1; j++) {
				if (a[j] > 1) {
					a[j]--;
					seti.insert(j);
				} else {
					a[j] = 0;
				}
			}
		} else {
			res = res + "0";
		}
	}
	cout << res << endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

using namespace std;

int main(){
	int n, m;
	cin >> n >> m;
	vector<int> v(m);
	for (int i = 0; i < m; i++) {
		int t;
		cin >> t;
		v[i] = t;
	}
	int map_size = 0;

	map<int, bool> mepi;
	string res = "";
	for (int i = 0; i < m; i++) {
		int curr = v[i];
		if (mepi.find(curr) == mepi.end()) {
			map_size++;
			if (map_size >= n) {
				res = res + "1";
				mepi[curr] = true;
			} else {
				res = res + "0";
				mepi[curr] = false;
			}
		} else {
			if (mepi[curr]) {
				res = res + "1";
			} else {
				res = res + "0";
			}
		}
	}

	cout << res << endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>

using namespace std;

int main(){
	int n, m;
	cin >> n >> m;
	int a[100001];
	for (int i = 0; i < 100001; i++) {
		a[i] = 0;
	}
	vector<int> v(m);
	for (int i = 0; i < m; i++) {
		int t;
		cin >> t;
		v[i] = t;
	}
	string res = "";
	set<int> seti;
	for (int i = 0; i < m; i++) {
		int curr = v[i];
		a[curr]++;
		seti.insert(curr);
		if (seti.size() >= n) {
			res = res + "1";
			seti.clear();
			for (int j = 0; j < 100001; j++) {
				if (a[j] > 1) {
					a[j]--;
				} else {
					a[j] = 0;
				}
			}
		} else {
			res = res + "0";
		}
	}
	cout << res << endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

using namespace std;

int main(){
	int n, m;
	cin >> n >> m;
	vector<int> v(m);
	for (int i = 0; i < m; i++) {
		int t;
		cin >> t;
		v[i] = t;
	}

	int map_size = 0;
	map<int, bool> mepi;
	string res = "";
	for (int i = 0; i < m; i++) {
		int curr = v[i];
		// cout << "cuuu " << curr << endl;
		if (mepi.find(curr) == mepi.end()) {
			map_size++;
			if (map_size >= n && curr >= 1 && curr <= n) {
				res = res + "1";
				mepi[curr] = true;
			} else {
				res = res + "0";
				mepi[curr] = false;
			}
		} else {
			if (mepi[curr]) {
				res = res + "1";
			} else {
				res = res + "0";
			}
		}
	}

	cout << res << endl;
	return 0;
}


#include <stdio.h>
#include <string.h>

#define N 110000

int a[N], vis[N];

int main() {
    int n, m;
    while (scanf("%d%d", &n, &m) != EOF) {
        int cnt = 0;
        memset(vis, 0, sizeof(vis));
        for (int i = 0; i < m; ++i) scanf("%d", &a[i]);
        for (int i = 0; i < m; ++i) {
            if (a[i] >= 1 && a[i! <= n && vis[a[i]]) { vis[a[i]] = 1; cnt++; }
            if (cnt == n) {
                printf("1");
                cnt = 0;
                for (int j = 0; j < n + 10; ++j) vis[j] = 0;
            }
            else printf("0");
        }
    }
    return 0;
}


#include <stdio.h>
#include <string.h>

#define N 110000

int a[N], vis[N];

int main() {
    int n, m;
    while (scanf("%d%d", &n, &m) != EOF) {
        int cnt = 0;
        memset(vis, 0, sizeof(vis));
        for (int i = 0; i < m; ++i) scanf("%d", &a[i]);
        for (int i = 0; i < m; ++i) {
            if (!vis[a[i]]) { vis[a[i]] = 1; cnt++; }
            if (cnt == n) {
                printf("1");
                cnt = 0;
                for (int j = 0; j < n + 10; ++j) vis[j] = 0;
            }
            else printf("0");
        }
        puts("");
    }
    return 0;
}


#include <stdio.h>
#include <string.h>

#define N 110000

int a[N], vis[N];

int main() {
    int n, m;
    while (scanf("%d%d", &n, &m) != EOF) {
        int cnt = 0;
        memset(vis, 0, sizeof(vis));
        for (int i = 0; i < m; ++i) scanf("%d", &a[i]);
        for (int i = 0; i < m; ++i) {
            if (a[i] >= 1 && a[i] <= n && !vis[a[i]]) { vis[a[i]] = 1; cnt++; }
            if (cnt == n) {
                printf("1");
                cnt = 0;
                for (int j = 0; j < n + 10; ++j) vis[j] = 0;
            }
            else printf("0");
        }
    }
    return 0;
}


#include <stdio.h>
#include <string.h>

#define N 110000

int a[N], vis[N];

int main() {
    int n, m;
    while (scanf("%d%d", &n, &m) != EOF) {
        int cnt = 0;
        memset(vis, 0, sizeof(vis));
        for (int i = 0; i < m; ++i) scanf("%d", &a[i]);
        for (int i = 0; i < m; ++i) {
            if (a[i] >= 1 && a[i] <= n && vis[a[i]]) { vis[a[i]] = 1; cnt++; }
            if (cnt == n) {
                printf("1");
                cnt = 0;
                for (int j = 0; j < n + 10; ++j) vis[j] = 0;
            }
            else printf("0");
        }
    }
    return 0;
}


#include <stdio.h>
#include <string.h>

#define N 110000

int a[N], vis[N];

int main() {
    int n, m;
    while (scanf("%d%d", &n, &m) != EOF) {
        int cnt = 0;
        memset(vis, 0, sizeof(vis));
        for (int i = 0; i < m; ++i) scanf("%d", &a[i]);
        for (int i = 0; i < m; ++i) {
            if (!vis[a[i]]) { vis[a[i]] = 1; cnt++; }
            if (cnt == n) {
                printf("1");
                cnt = 0;
                memset(vis, 0, sizeof(int) * (n + 10));
            }
            else printf("0");
        }
        puts("");
    }
    return 0;
}


#include <stdio.h>
#include <string.h>

#define N 110000

int a[N], vis[N];

int main() {
    int n, m;
    while (scanf("%d%d", &n, &m) != EOF) {
        int cnt = 0;
        memset(vis, 0, sizeof(vis));
        for (int i = 0; i < m; ++i) scanf("%d", &a[i]);
        for (int i = 0; i < m; ++i) {
            vis[a[i]]++;
            if (vis[a[i]] == 1) ++cnt;
            if (cnt == n) {
                printf("1");
                for (int i = 1; i <= n; ++i) {
                    vis[i]--;
                    if (vis[i] == 0) cnt--;
                }
            }
            else printf("0");
        }
        puts("");
    }
    return 0;
}
/*
3 9
1 1 1 2 2 2 3 3 3
*/


//
//  main.cpp
//  1_14_B
//
//  Created by 박다원 on 13/01/2019.
//  Copyright © 2019 Park Dawon. All rights reserved.
//

#include <iostream>

using namespace std;

int n;
int m;
int arr[100004];
int cnt[100004];
char str[100004];

int main(int argc, const char * argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    cin >> n >> m;
    for(int i = 1; i <= m; i++)
    {
        cin >> arr[i];
    }

    int make_num = 1;
    for(int i = 1; i <= m; i++)
    {
        cnt[arr[i]]++;
        bool ans_Flag = false;
        if(i >= n)
        {
            for(int j = 1; j <= n; j++)
            {
                if(cnt[j] < make_num)
                    break;

                if(j == n)
                {
                    make_num++;
                    ans_Flag = true;
                }
            }
        }

        if(ans_Flag)
            str[i] = '1';
        else
            str[i] = '0';
    }
    cout << str << endl;

    return 0;
}


#include <iostream>

using namespace std;

int n;
int m;
int arr[100004];
int cnt[100004];
char str[100004];

int main(int argc, const char * argv[])
{
    scanf("%d %d", &n, &m);
    for(int i = 0; i < m; i++)
    {
        scanf("%d", &arr[i]);
    }

    int make_num = 1;
    for(int i = 0; i < m; i++)
    {
        cnt[arr[i]]++;
        bool ans_Flag = false;
        if(i >= n-1)
        {
            for(int j = 1; j <= n; j++)
            {
                if(cnt[j] < make_num)
                    break;

                if(j == n)
                {
                    make_num++;
                    ans_Flag = true;
                }
            }
        }

        if(ans_Flag)
            str[i] = '1';
        else
            str[i] = '0';
    }
    str[m] = '\0';
    printf("%s\n", str);

    return 0;
}


#include <iostream>

using namespace std;

int n;
int m;
int arr[100004];
int cnt[100004];
char str[100004];

int main(int argc, const char * argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    cin >> n >> m;
    for(int i = 1; i <= m; i++)
    {
        cin >> arr[i];
    }

    int make_num = 1;
    for(int i = 1; i <= m; i++)
    {
        cnt[arr[i]]++;
        bool ans_Flag = false;
        if(i >= n)
        {
            for(int j = 1; j <= n; j++)
            {
                if(cnt[j] < make_num)
                    break;

                if(j == n)
                {
                    make_num++;
                    ans_Flag = true;
                }
            }
        }

        if(ans_Flag)
            str[i] = '1';
        else
            str[i] = '0';
    }
    str[m] = '\0'
    cout << str << endl;

    return 0;
}


#include <iostream>
using namespace std;
int a[100005];
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
    int n,t,i,j,k,y,z,c=0,m,cnt=0,mx=0;
    scanf("%d %d",&n,&m);
    mx=m+5;
    char s[m+5];
    int b[m+5];
    for(i=0;i<m;i++){
        scanf("%d",&b[i]);
        a[b[i]]++;
        if(i>=n-1){
            bool f=0;
            for(j=1;j<=n;j++){
                if(a[j]>cnt) continue;
                else {
                    f=1;
                    break;
                }
            }
            if(f==0) {s[i]='1'; cnt++;}
            else s[i]='0';
        }
        else s[i]='0';
    }
    s[i]='\0';
    printf("%s",s);
}


//
//  main.cpp
//  1_14_B
//
//  Created by 박다원 on 13/01/2019.
//  Copyright © 2019 Park Dawon. All rights reserved.
//

#include <iostream>
#include <map>

using namespace std;

int n;
int m;
int arr[200004];
int cnt[200004];

map<int, int> mp;

int main(int argc, const char * argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    cin >> n >> m;
    for(int i = 1; i <= m; i++)
    {
        cin >> arr[i];
    }

    int make_num = 1;
    for(int i = 1; i <= m; i++)
    {
        cnt[arr[i]]++;
        bool ans_Flag = false;
        if(i >= n)
        {
            for(int j = 1; j <= n; j++)
            {
                if(cnt[j] < make_num)
                    break;

                if(j == n)
                {
                    make_num++;
                    ans_Flag = true;
                }
            }
        }

        if(ans_Flag)
            cout << 1;
        else
            cout << 0;
    }
    cout << endl;

    return 0;
}


//
//  main.cpp
//  1_14_B
//
//  Created by 박다원 on 13/01/2019.
//  Copyright © 2019 Park Dawon. All rights reserved.
//

#include <iostream>

using namespace std;

int n;
int m;
int arr[100004];
int cnt[100004];
int line[100004];
char str[100004];

int main(int argc, const char * argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    cin >> n >> m;
    for(int i = 1; i <= m; i++)
    {
        cin >> arr[i];
    }

    for(int i = 0; i < 100004; i++)
    {
        line[i] = n;
    }

    int make_num = 0;
    for(int i = 1; i <= m; i++)
    {
        line[cnt[arr[i]]]--;
        cnt[arr[i]]++;

        if(line[make_num] == 0)
        {
            make_num++;
            str[i] = '1';
        }
        else
        {
            str[i] = '0';
        }
    }
    cout << str << endl;

    return 0;
}


#include <iostream>

using namespace std;

int n;
int m;
int arr[100004];
int cnt[100004];
char str[100004];

int main(int argc, const char * argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    cin >> n >> m;
    for(int i = 1; i <= m; i++)
    {
        cin >> arr[i];
    }

    int make_num = 1;
    for(int i = 1; i <= m; i++)
    {
        cnt[arr[i]]++;
        bool ans_Flag = false;
        if(i >= n)
        {
            for(int j = 1; j <= n; j++)
            {
                if(cnt[j] < make_num)
                    break;

                if(j == n)
                {
                    make_num++;
                    ans_Flag = true;
                }
            }
        }

        if(ans_Flag)
            str[i] = '1';
        else
            str[i] = '0';
    }
    str[m] = '\0'
    cout << &str << endl;

    return 0;
}


//
//  main.cpp
//  아니 B번 ㅡㅡ
//
//  Created by 박다원 on 14/01/2019.
//  Copyright © 2019 Park Dawon. All rights reserved.
//

#include <iostream>

using namespace std;

int cnt[100004];
char str[100004];

int main(int argc, const char * argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n;
    int m;
    scanf("%d %d", &n, &m);

    int make_num = 0;

    for(int i = 0; i < m; i++)
    {
        int num;
        scanf("%d", &num);
        cnt[num]++;

        if(i >= n-1)
        {
            bool ans_Flag = false;
            for(int j = 1; j <= n; j++)
            {
                if(cnt[j] > make_num)
                {
                    continue;
                }
                else
                {
                    ans_Flag = true;
                    break;
                }
            }
            if(ans_Flag)
            {
                str[i] = '0';
            }
            else
            {
                str[i] = '1';
                make_num++;
            }
        }
        else
            str[i] = '0';

    }
    str[m] = '\0';
    printf("%s\n", str);

    return 0;
}


//
//  main.cpp
//  아니 B번 ㅡㅡ
//
//  Created by 박다원 on 14/01/2019.
//  Copyright © 2019 Park Dawon. All rights reserved.
//

#include <iostream>

using namespace std;

int n;
int m;
int cnt[100004];

int main(int argc, const char * argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    scanf("%d %d", &n, &m);

    int make_num = 1;
    char str[m+5];
    int i;
    for(i = 0; i < m; i++)
    {
        int num;
        scanf("%d", &num);
        cnt[num]++;
        bool ans_Flag = false;
        if(i >= n-1)
        {
            for(int j = 1; j <= n; j++)
            {
                if(cnt[j] < make_num)
                    break;

                if(j == n)
                {
                    make_num++;
                    ans_Flag = true;
                }
            }
        }

        if(ans_Flag)
            str[i] = '1';
        else
            str[i] = '0';
    }
    str[m] = '\0';
    printf("%s\n", str);

    return 0;
}


#include <iostream>

using namespace std;

int n;
int m;
int arr[100004];
int cnt[100004];
char str[100004];

int main(int argc, const char * argv[])
{
    scanf("%d %d", &n, &m);
    for(int i = 1; i <= m; i++)
    {
        scanf("%d", &arr[i]);
    }

    int make_num = 1;
    for(int i = 1; i <= m; i++)
    {
        cnt[arr[i]]++;
        bool ans_Flag = false;
        if(i >= n)
        {
            for(int j = 1; j <= n; j++)
            {
                if(cnt[j] < make_num)
                    break;

                if(j == n)
                {
                    make_num++;
                    ans_Flag = true;
                }
            }
        }

        if(ans_Flag)
            str[i] = '1';
        else
            str[i] = '0';
    }
    str[m] = '\0'
    printf("%s\n", str);

    return 0;
}


#include <iostream>

using namespace std;

int n;
int m;
int cnt[100004];

int main(int argc, const char * argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    scanf("%d %d", &n, &m);

    int make_num = 1;
    char str[100004];
    for(int i = 0; i < m; i++)
    {
        int num;
         scanf("%d", &num);
        cnt[num]++;
        bool ans_Flag = false;
        if(i >= n-1)
        {
            for(int j = 1; j <= n; j++)
            {
                if(cnt[j] < make_num)
                    break;

                if(j == n)
                {
                    make_num++;
                    ans_Flag = true;
                }
            }
        }

        if(ans_Flag)
            str[i] = '1';
        else
            str[i] = '0';
    }
    str[m] = '\0';
    printf("%s\n", str);

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int a[100005];
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
    int n,t,i,j,k,x,y,z,c=0,m,cnt=0,mx=0;
    scanf("%d %d",&n,&m);
    mx=m+5;
    char s[m+5];
    int b[m+5];
    for(i=0;i<m;i++){
        scanf("%d",&b[i]);
        a[b[i]]++;
        if(i>=n-1){
            bool f=0;
            for(j=1;j<=n;j++){
                if(a[j]>cnt) continue;
                else {
                    f=1;
                    break;
                }
            }
            if(f==0) {s[i]='1'; cnt++;}
            else s[i]='0';
        }
        else s[i]='0';
    }
    s[i]='\0';
    printf("%s",s);
}


//
//  main.cpp
//  아니 B번 ㅡㅡ
//
//  Created by 박다원 on 14/01/2019.
//  Copyright © 2019 Park Dawon. All rights reserved.
//

#include <iostream>

using namespace std;

int cnt[100004];

int main(int argc, const char * argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n;
    int m;
    scanf("%d %d", &n, &m);

    int make_num = 0;
    char str[m+5];
    int i, num;
    for(i = 0; i < m; i++)
    {
        scanf("%d", &num);
        cnt[num]++;

        if(i >= n-1)
        {
            bool ans_Flag = false;
            for(int j = 1; j <= n; j++)
            {
                if(cnt[j] > make_num)
                {
                    continue;
                }
                else
                {
                    ans_Flag = true;
                }
            }
            if(ans_Flag)
            {
                str[i] = '0';
            }
            else
            {
                str[i] = '1';
                make_num++;
            }
        }
        else
            str[i] = '0';

    }
    str[m] = '\0';
    printf("%s\n", str);

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int a[100005];
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
    int n,t,i,j,k,y,z,c=0,m,cnt=0,mx=0;
    scanf("%d %d",&n,&m);
    mx=m+5;
    char s[m+5];
    int b[m+5];
    for(i=0;i<m;i++){
        scanf("%d",&b[i]);
        a[b[i]]++;
        if(i>=n-1){
            bool f=0;
            for(j=1;j<=n;j++){
                if(a[j]>cnt) continue;
                else {
                    f=1;
                    break;
                }
            }
            if(f==0) {s[i]='1'; cnt++;}
            else s[i]='0';
        }
        else s[i]='0';
    }
    s[i]='\0';
    printf("%s",s);
}


//
//  main.cpp
//  아니 B번 ㅡㅡ
//
//  Created by 박다원 on 14/01/2019.
//  Copyright © 2019 Park Dawon. All rights reserved.
//
# pragma GCC optimize ("O3")
# pragma GCC optimize ("Ofast")
# pragma GCC optimize ("unroll-loops")

#include <iostream>

using namespace std;

int cnt[100004];
char str[100004];

int main(int argc, const char * argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n;
    int m;
    scanf("%d %d", &n, &m);

    int make_num = 0;

    for(int i = 0; i < m; i++)
    {
        int num;
        scanf("%d", &num);
        cnt[num]++;

        if(i >= n-1)
        {
            bool ans_Flag = false;
            for(int j = 1; j <= n; j++)
            {
                if(cnt[j] > make_num)
                {
                    continue;
                }
                else
                {
                    ans_Flag = true;
                    break;
                }
            }
            if(ans_Flag)
            {
                str[i] = '0';
            }
            else
            {
                str[i] = '1';
                make_num++;
            }
        }
        else
            str[i] = '0';

    }
    str[m] = '\0';
    printf("%s\n", str);

    return 0;
}


#include <iostream>

using namespace std;

int n;
int m;
int arr[100004];
int cnt[100004];
char str[100004];

int main(int argc, const char * argv[])
{
    scanf("%d %d", &n, &m);
    for(int i = 0; i < m; i++)
    {
        scanf("%d", &arr[i]);
    }

    int make_num = 1;
    for(int i = 0; i < m; i++)
    {
        cnt[arr[i]]++;
        bool ans_Flag = false;
        if(i >= n)
        {
            for(int j = 1; j <= n; j++)
            {
                if(cnt[j] < make_num)
                    break;

                if(j == n)
                {
                    make_num++;
                    ans_Flag = true;
                }
            }
        }

        if(ans_Flag)
            str[i] = '1';
        else
            str[i] = '0';
    }
    str[m] = '\0';
    printf("%s\n", str);

    return 0;
}


//
//  main.cpp
//  아니 B번 ㅡㅡ
//
//  Created by 박다원 on 14/01/2019.
//  Copyright © 2019 Park Dawon. All rights reserved.
//

#include <iostream>

using namespace std;

int cnt[100004];
char str[100004];

int main(int argc, const char * argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n;
    int m;
    scanf("%d %d", &n, &m);

    int make_num = 0;

    for(int i = 0; i < m; i++)
    {
        int num;
        scanf("%d", &num);
        cnt[num]++;

        if(i >= n-1)
        {
            bool ans_Flag = false;
            for(int j = 1; j <= n; j++)
            {
                if(cnt[j] > make_num)
                {
                    continue;
                }
                else
                {
                    ans_Flag = true;
                }
            }
            if(ans_Flag)
            {
                str[i] = '0';
            }
            else
            {
                str[i] = '1';
                make_num++;
            }
        }
        else
            str[i] = '0';

    }
    str[m] = '\0';
    printf("%s\n", str);

    return 0;
}


#include <iostream>

using namespace std;

int n;
int m;
int arr[100004];
int cnt[100004];
char str[100004];

int main(int argc, const char * argv[])
{
    scanf("%d %d", &n, &m);
    for(int i = 1; i <= m; i++)
    {
        scanf("%d", &arr[i]);
    }

    int make_num = 1;
    for(int i = 1; i <= m; i++)
    {
        cnt[arr[i]]++;
        bool ans_Flag = false;
        if(i >= n)
        {
            for(int j = 1; j <= n; j++)
            {
                if(cnt[j] < make_num)
                    break;

                if(j == n)
                {
                    make_num++;
                    ans_Flag = true;
                }
            }
        }

        if(ans_Flag)
            str[i] = '1';
        else
            str[i] = '0';
    }
    str[m] = '\0';
    printf("%s\n", str);

    return 0;
}


#include <iostream>

using namespace std;

int n;
int m;
int arr[100004];
int cnt[100004];
char str[100004];

int main(int argc, const char * argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    cin >> n >> m;
    for(int i = 1; i <= m; i++)
    {
        cin >> arr[i];
    }

    int make_num = 1;
    for(int i = 1; i <= m; i++)
    {
        cnt[arr[i]]++;
        bool ans_Flag = false;
        if(i >= n)
        {
            for(int j = 1; j <= n; j++)
            {
                if(cnt[j] < make_num)
                    break;

                if(j == n)
                {
                    make_num++;
                    ans_Flag = true;
                }
            }
        }

        if(ans_Flag)
            str[i] = '1';
        else
            str[i] = '0';
    }
    str[m] = '\0';
    cout << str << endl;

    return 0;
}


//
//  main.cpp
//  아니 B번 ㅡㅡ
//
//  Created by 박다원 on 14/01/2019.
//  Copyright © 2019 Park Dawon. All rights reserved.
//

#include <iostream>

using namespace std;

int n;
int m;
int cnt[100004];

int main(int argc, const char * argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    scanf("%d %d", &n, &m);

    int make_num = 1;
    char str[m+5];
    int i, num;
    for(i = 0; i < m; i++)
    {
        scanf("%d", &num);
        cnt[num]++;

        if(i >= n-1)
        {
            bool ans_Flag = false;
            for(int j = 1; j <= n; j++)
            {
                if(cnt[j] < make_num)
                    break;

                if(j == n)
                {
                    make_num++;
                    ans_Flag = true;
                }
            }
            if(ans_Flag)
                str[i] = '1';
            else
                str[i] = '0';
        }
        else
            str[i] = '0';

    }
    str[m] = '\0';
    printf("%s\n", str);

    return 0;
}


//
//  main.cpp
//  아니 B번 ㅡㅡ
//
//  Created by 박다원 on 14/01/2019.
//  Copyright © 2019 Park Dawon. All rights reserved.
//

#include <iostream>

using namespace std;

int cnt[100004];
char str[100004];

int main(int argc, const char * argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n;
    int m;
    scanf("%d %d", &n, &m);

    int make_num = 0;

    int i, num;
    for(i = 0; i < m; i++)
    {
        scanf("%d", &num);
        cnt[num]++;

        if(i >= n-1)
        {
            bool ans_Flag = false;
            for(int j = 1; j <= n; j++)
            {
                if(cnt[j] > make_num)
                {
                    continue;
                }
                else
                {
                    ans_Flag = true;
                }
            }
            if(ans_Flag)
            {
                str[i] = '0';
            }
            else
            {
                str[i] = '1';
                make_num++;
            }
        }
        else
            str[i] = '0';

    }
    str[m] = '\0';
    printf("%s\n", str);

    return 0;
}


//
//  main.cpp
//  아니 B번 ㅡㅡ
//
//  Created by 박다원 on 14/01/2019.
//  Copyright © 2019 Park Dawon. All rights reserved.
//

#include <iostream>

using namespace std;

int n;
int m;
int cnt[100004];

int main(int argc, const char * argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    scanf("%d %d", &n, &m);

    int make_num = 1;
    char str[m+5];
    for(int i = 0; i < m; i++)
    {
        int num;
        scanf("%d", &num);
        cnt[num]++;
        bool ans_Flag = false;
        if(i >= n-1)
        {
            for(int j = 1; j <= n; j++)
            {
                if(cnt[j] < make_num)
                    break;

                if(j == n)
                {
                    make_num++;
                    ans_Flag = true;
                }
            }
        }

        if(ans_Flag)
            str[i] = '1';
        else
            str[i] = '0';
    }
    str[m] = '\0';
    printf("%s\n", str);

    return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main(){

    int n,m,num;
    vector<int> indx;
    bitset<10000000> verify;

    indx.push_back(0);

    cin >> n >> m;

    for(int i=1; i<=n; i++){
        indx.push_back(0);
        verify[i] = 1;
    }

    while(m--){
        cin >> num;
        indx[num]++;
        verify[num] = 0;

        if(verify == 0){
            cout << "1";
            for(int i=1; i<=indx.size(); i++){
                indx[i]--;
                if(indx[i] == 0){
                    verify[1] = 1;
                }
            }
        }else{
            cout << "0";
        }

    }

    cout << endl;

    return 0;
}


/*
 *	 author: lucas_medeiros - github.com/medeiroslucas
 *	   team: Lo and Behold ++
 *	created: 05-10-2019 19:45:34
 *	contest: 1100
 *	problem: B
 *	 solved: False
*/

#include <bits/stdc++.h>

#define DEBUG false
#define coutd if(DEBUG) cout
#define debugf if(DEBUG) printf
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define sz size()

using namespace std;

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
const double PI = acos(-1);
const double EPS = 1e-9;

int main(){
	ios_base::sync_with_stdio(false);

    int n, m, num, cont=0;
    vector<int> indx;
    string ans="";

    cin >> n >> m;

	cont = n;

    for(int i=0; i<=n; i++){
        indx.push_back(0);
    }

    while(m--){
        cin >> num;
		if(!indx[num]) cont--;
        indx[num]++;

        if(cont == 0){
            ans += "1";

            for(int i=0; i<(int)indx.size(); i++){
                indx[i]--;
                if(indx[i] == 0) cont++;
            }
        }else{
            ans += "0";
        }

    }

    cout << ans << endl;

	return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main(){

    int n,m,num;
    vector<int> indx;
    bitset<10000000> verify;

    indx.push_back(0);

    cin >> n >> m;

    if(n==1){
        for(int i=0; i<=m; i++){
            cout << "1";
        }
    }else{

        for(int i=1; i<=n; i++){
            indx.push_back(0);
            verify[i] = 1;
        }

        while(m--){
            cin >> num;
            indx[num]++;
            verify[num] = 0;

            if(verify == 0){
                cout << "1";
                for(int i=1; i<=indx.size(); i++){
                    indx[i]--;
                    if(indx[i] == 0){
                        verify[i] = 1;
                    }
                }
            }else{
                cout << "0";
            }

        }
    }

    cout << endl;

    return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main(){

    int n,m,num, i;
    vector<int> indx;
    bitset<10000000> verify;
    string ans="";

    indx.push_back(0);

    cin >> n >> m;

    for(i=1; i<=n; i++){
        indx.push_back(0);
        verify[i] = 1;
    }

    while(m--){
        cin >> num;
        indx[num]++;
        verify[num] = 0;

        if(verify == 0){
            ans += "1";
            i=0;
            while(i<indx.size()){
                indx[i+1]--;
                if(indx[i+1] == 0){
                    verify[i+1] = 1;
                }
                i++;
            }
        }else{
            ans += "0";
        }

    }

    cout << ans << endl;

    return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main(){

    int n,m,num, i;
    vector<int> indx;
    bitset<10000000> verify;

    indx.push_back(0);

    cin >> n >> m;

    for(i=1; i<=n; i++){
        indx.push_back(0);
        verify[i] = 1;
    }

    while(m--){
        cin >> num;
        indx[num]++;
        verify[num] = 0;

        if(verify == 0){
            cout << "1";
            for(i=1; i<=indx.size(); i++){
                indx[i]--;
                if(indx[i] == 0){
                    verify[i] = 1;
                }
            }
        }else{
            cout << "0";
        }

    }

    cout << endl;

    return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main(){

    int n,m,num;
    vector<int> indx;
    bitset<10000000> verify;

    indx.push_back(0);

    cin >> n >> m;

    for(int i=1; i<=n; i++){
        indx.push_back(0);
        verify[i] = 1;
    }

    while(m--){
        cin >> num;
        indx[num]++;
        verify[num] = 0;

        if(verify == 0){
            cout << "1";
            for(int i=1; i<=indx.size(); i++){
                indx[i]--;
                if(indx[i] == 0){
                    verify[i] = 1;
                }
            }
        }else{
            cout << "0";
        }

    }

    cout << endl;

    return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main(){

    int n,m,num, i;
    vector<int> indx;
    bitset<10000000> verify;
    string ans="";

    indx.push_back(0);

    cin >> n >> m;

    for(i=1; i<=n; i++){
        indx.push_back(0);
        verify[i] = 1;
    }

    while(m--){
        cin >> num;
        indx[num]++;
        verify[num] = 0;

        if(verify == 0){
            ans += "1";
            for(i=1; i<=indx.size(); i++){
                indx[i]--;
                if(indx[i] == 0){
                    verify[i] = 1;
                }
            }
        }else{
            ans += "0";
        }

    }

    cout << ans << endl;

    return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main(){

    int n,m,num;
    vector<int> indx;
    bitset<10000000> verify;

    indx.push_back(0);

    cin >> n >> m;

    if(n==1){
        for(int i=0; i<m; i++){
            cout << "1";
        }
    }else{

        for(int i=1; i<=n; i++){
            indx.push_back(0);
            verify[i] = 1;
        }

        while(m--){
            cin >> num;
            indx[num]++;
            verify[num] = 0;

            if(verify == 0){
                cout << "1";
                for(int i=1; i<=indx.size(); i++){
                    indx[i]--;
                    if(indx[i] == 0){
                        verify[i] = 1;
                    }
                }
            }else{
                cout << "0";
            }

        }
    }

    cout << endl;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define mx 100007
#define ll long long int
typedef pair<ll,ll>pii;
vector<ll>v,vec[mx+3];
map<ll,ll>mep;
map<string,ll>ms;
map<char,ll>mc;
int a[mx+4],n,i,j,pf[mx+4];

void seive()
{
    int x=sqrt(mx);
    for(int i=2;i<=mx;i+=2) pf[i]=2;
    for(int i=3;i<=mx;i+=2) pf[i]=i;
    for(int i=3;i<=x;i+=2){
        if(pf[i]==i){
            for(int j=i*i;j<=mx;j+=i){
                if(pf[j]==j) pf[j]=i;
            }
        }
    }
}
int main()
{
    /*int p=65;
    for(int i=1;i<=26;i++){
        mc[p++]=i;
    }*/
    //seive();
   ll n,m;
   cin>>n>>m;
   map<ll,ll>me;
   for(int i=0;i<m;i++){
    cin>>a[i];
   }
   for(int i=0;i<m;i++){
        while(1){
            if(i==m) break;
            me[a[i]]++;
            if(me.size()==n){
                cout<<1;
                me.clear();
                break;
            }
            else{
                    cout<<0;
            i++;
            }
        }
   }

}


#include<bits/stdc++.h>
using namespace std;
#define mx 100007
#define ll long long int
typedef pair<ll,ll>pii;
vector<ll>v,vec[mx+3];

map<string,ll>ms;
map<char,ll>mc;
int a[mx+4],n,i,j,pf[mx+4];

void seive()
{
    int x=sqrt(mx);
    for(int i=2;i<=mx;i+=2) pf[i]=2;
    for(int i=3;i<=mx;i+=2) pf[i]=i;
    for(int i=3;i<=x;i+=2){
        if(pf[i]==i){
            for(int j=i*i;j<=mx;j+=i){
                if(pf[j]==j) pf[j]=i;
            }
        }
    }
}
int main()
{
    /*int p=65;
    for(int i=1;i<=26;i++){
        mc[p++]=i;
    }*/
    //seive();
   int n,m;
   scanf("%d%d",&n,&m);
   map<int,int>mep;
   for(int i=0;i<m;i++){
    scanf("%d",&a[i]);
   }
   bool vis[mx];
   int cnt=0;
   set<int>s;
   for(int i=0;i<m;i++){
        s.insert(a[i]);
        if(s.size()==n){
            cout<<1;
            s.clear();
        }
        else{
            cout<<0;
        }
        /*mep[a[i]]++;
        if(mep.size()==n){
            printf("1");
            mep.clear();
        }
        else{
            printf("0");
        }*/
   }
    cout<<endl;

}


#include<bits/stdc++.h>
using namespace std;
#define mx 100007
#define ll long long int
typedef pair<ll,ll>pii;
vector<ll>v,vec[mx+3];
map<ll,ll>mep;
map<string,ll>ms;
map<char,ll>mc;
int a[mx+4],n,i,j,pf[mx+4];

void seive()
{
    int x=sqrt(mx);
    for(int i=2;i<=mx;i+=2) pf[i]=2;
    for(int i=3;i<=mx;i+=2) pf[i]=i;
    for(int i=3;i<=x;i+=2){
        if(pf[i]==i){
            for(int j=i*i;j<=mx;j+=i){
                if(pf[j]==j) pf[j]=i;
            }
        }
    }
}
int main()
{
    /*int p=65;
    for(int i=1;i<=26;i++){
        mc[p++]=i;
    }*/
    //seive();
   ll n,m;
   cin>>n>>m;
   map<ll,ll>mep;
   for(int i=0;i<m;i++){
    cin>>a[i];
   }
   for(int i=0;i<m;i++){
        mep[a[i]]++;
        if(mep.size()==n){
            cout<<1;
            mep.clear();
        }
        else{
            cout<<0;
        }
   }
    cout<<endl;

}


#include<bits/stdc++.h>
using namespace std;
#define mx 100007
#define ll long long int
typedef pair<ll,ll>pii;
vector<ll>v,vec[mx+3];
map<ll,ll>mep;
map<string,ll>ms;
map<char,ll>mc;
int a[mx+4],n,i,j,pf[mx+4];

void seive()
{
    int x=sqrt(mx);
    for(int i=2;i<=mx;i+=2) pf[i]=2;
    for(int i=3;i<=mx;i+=2) pf[i]=i;
    for(int i=3;i<=x;i+=2){
        if(pf[i]==i){
            for(int j=i*i;j<=mx;j+=i){
                if(pf[j]==j) pf[j]=i;
            }
        }
    }
}
int main()
{
    /*int p=65;
    for(int i=1;i<=26;i++){
        mc[p++]=i;
    }*/
    //seive();
   int n,m;
   scanf("%d%d",&n,&m);
   map<int,int>mep;
   for(int i=0;i<m;i++){
    scanf("%d",&a[i]);
   }
   for(int i=0;i<m;i++){
        mep[a[i]]++;
        if(mep.size()==n){
            printf("1");
            mep.clear();
        }
        else{
            printf("0");
        }
   }
    cout<<endl;

}


#include<bits/stdc++.h>
using namespace std;
#define mx 100007
#define ll long long int
typedef pair<ll,ll>pii;
vector<ll>vec[mx+3];

map<string,ll>ms;
map<char,ll>mc;
int a[mx+4],n,i,j,pf[mx+4];

void seive()
{
    int x=sqrt(mx);
    for(int i=2;i<=mx;i+=2) pf[i]=2;
    for(int i=3;i<=mx;i+=2) pf[i]=i;
    for(int i=3;i<=x;i+=2){
        if(pf[i]==i){
            for(int j=i*i;j<=mx;j+=i){
                if(pf[j]==j) pf[j]=i;
            }
        }
    }
}
struct node
{
    int a;
    int b;
    node(){}
    node(int aa,int bb)
    {
        a=aa;
        b=bb;
    }
};
vector<node>v;
int main()
{
    /*int p=65;
    for(int i=1;i<=26;i++){
        mc[p++]=i;
    }*/
    //seive();
   int n,m;
   scanf("%d%d",&n,&m);

   map<int,int>mep,meep;
   for(int i=0;i<m;i++){
    scanf("%d",&a[i]);
   }
   for(int i=0;i<m;i++){
        meep[a[i]]++;
   }
   for(int i=0;i<m;i++){

        mep[a[i]]++;
        if(mep.size()==n){
            printf("1");
            v.clear();
            for(auto j=mep.begin();j!=mep.end();j++){
                //cout<<j->first<<" "<<j->second<<endl;
                mep[j->first]--;
                if(mep[j->first]!=0){
                    v.push_back(node(j->first,j->second));
                }
            }
            mep.clear();
            for(int j=0;j<v.size();j++){
                mep[v[j].a]=v[j].b;
            }
            //cout<<endl;

        }
        else{
            printf("0");
        }
   }
    cout<<endl;

}


#include<bits/stdc++.h>
using namespace std;
#define mx 100007
#define ll long long int
typedef pair<ll,ll>pii;
vector<ll>v,vec[mx+3];
map<ll,ll>mep;
map<string,ll>ms;
map<char,ll>mc;
int a[mx+4],n,i,j,pf[mx+4];

void seive()
{
    int x=sqrt(mx);
    for(int i=2;i<=mx;i+=2) pf[i]=2;
    for(int i=3;i<=mx;i+=2) pf[i]=i;
    for(int i=3;i<=x;i+=2){
        if(pf[i]==i){
            for(int j=i*i;j<=mx;j+=i){
                if(pf[j]==j) pf[j]=i;
            }
        }
    }
}
int main()
{
    /*int p=65;
    for(int i=1;i<=26;i++){
        mc[p++]=i;
    }*/
    //seive();
   ll n,r;
   cin>>n>>r;
   double p=asin(6.4641016/(1.0*7.4641016));
   //cout<<(p*180)/(1.0*acos(-1))<<endl;
   double lo=0,hi=1e18,mid;
   for(int i=0;i<20000;i++){
        mid=(lo+hi)/2.0;
        double x=asin(mid/(1.0*(mid+r)));
        x=(x*180)/(1.0*acos(-1));
        x*=2;
         double ans=x*n;
        double j=abs(ans-360);
        //cout<<x*n<<"   "<<mid<<" "<<j<<endl;

        if(j<=0.0000001){
            cout<<fixed;
            cout<<setprecision(7);
            cout<<mid<<endl;
            break;

        }
        else if(ans>360){
            hi=mid;
        }
        else lo=mid;
   }

}


#include <bits/stdc++.h>

using namespace std;

int main() {
    long long n, m, i, j, k, actual, neiw, sum = 0;
    cin >> n >> m;
    vector <long long> v;
    vector <long long> visited(n , 0);
    for(i = 0; i < m; i++) {
        cin >> k;
        v.push_back(k);
    }
    for(i = 0; i < m; i++) {
        k = v[i];
        visited[k - 1] += 1;
        for(j = 0; j < n; j++)
            if(visited[j] == 0)
                break;
        if(j == n) {
            cout << 1;
            for(k = 0; k < n; k++)
                visited[k] -= 1;
        }
        else
            cout << 0;
    }
    cout << endl;
}
//3 11
//2 3 1 2 2 2 3 2 2 3 1


#include <bits/stdc++.h>

using namespace std;

int main() {
    int n, m, i, k;
    cin >> n >> m;
    int arr[100005], brr[100005];
    for(i = 0; i < m; i++) {
        cin >> k;
        arr[k]++;
        brr[arr[k]]++;
        if(brr[arr[k]] == n)
            cout << 1;
        else
            cout << 0;
    }
    cout << endl;
}
//3 11
//2 3 1 2 2 2 3 2 2 3 1


#include <bits/stdc++.h>

using namespace std;

int main() {
    long long n, m, i, j, k, actual, neiw, sum = 0;
    cin >> n >> m;
    vector <long long> v;
    vector <long long> visited(n , 0);
    for(i = 0; i < m; i++) {
        cin >> k;
        v.push_back(k);
    }
    actual = (n * (n + 1))/ 2;
    neiw = 1;
    for(i = 0; i < m; i++) {
        if(neiw == 1) {
            for(j = 0; j < n; j++)
                visited[j] = 0;
            neiw = 0;
            sum = 0;
        }
        k = v[i];
        if(visited[k - 1] == 0) {
            sum += k;
            visited[k - 1] = 1;
        }
        if(sum == actual) {
            cout << 1 ;
            neiw = 1;
        }
        else
            cout << 0 ;
    }
}
//3 11
//2 3 1 2 2 2 3 2 2 3 1


#include <bits/stdc++.h>
#define N 100001
using namespace std;
int arr[N], brr[N];
int main() {
    int n, m, i, k;
    cin >> n >> m;
    //int arr[N], brr[N];
    for(i = 0; i < m; i++) {
        cin >> k;
        arr[k]++;
        brr[arr[k]]++;
        if(brr[arr[k]] == n)
            cout << 1;
        else
            cout << 0;
    }
}
//3 11
//2 3 1 2 2 2 3 2 2 3 1


#include <bits/stdc++.h>

using namespace std;

int main() {
    long long n, m, i, j, k, actual, neiw, sum = 0;
    cin >> n >> m;
    if(n ==m) {
        for(i = 0;i < m; i++)
            cout << 0;
    }
    else {
    vector <long long> v;
    vector <long long> visited(n , 0);
    for(i = 0; i < m; i++) {
        cin >> k;
        v.push_back(k);
    }
    for(i = 0; i < m; i++) {
        k = v[i];
        visited[k - 1] += 1;
        for(j = 0; j < n; j++)
            if(visited[j] == 0)
                break;
        if(j == n) {
            cout << 1;
            for(k = 0; k < n; k++)
                visited[k] -= 1;
        }
        else
            cout << 0;
    }}
    cout << endl;
}
//3 11
//2 3 1 2 2 2 3 2 2 3 1


#include <bits/stdc++.h>

using namespace std;

int main() {
    long long n, m, i, j, k, sum;
    cin >> n >> m;
    vector <long long> v;
    vector <long long> visited(n , 0);
    for(i = 0; i < m; i++) {
        cin >> k;
        v.push_back(k);
        visited[k - 1] += 1;
    }
    auto it = min_element(visited.begin(), visited.end());
    k = *it;
    //flag = 0;
    vector <long long> imp;
    vector <long long> vis(n, 0);
    vector <long long> x(n, 0);
    sum = 0;
    for(i = 0; i < m; i++) {
        if(vis[v[i] - 1] ==0) {
            vis[v[i] - 1] = 1;
            sum += 1;
        }
        if(sum == n) {
            cout << 1;
            sum = 0;
            vis = x;
        }
        else
            cout << 0;
    }
     cout << endl;
}
//3 11
//2 3 1 2 2 2 3 2 2 3 1


#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    int a[n] = {0};
    int curr[n] = {0};
    long long full = n * (n + 1) / 2;
    long long cfull = 0;
    for (int i = 0; i < m; ++i){

        int d;
        cin >> d;
        ++a[d-1];

        if (curr[d-1] == 0){
            cfull += d;

        }
        curr[d-1] = 1;

        if (cfull == full){
            cout << 1;
            cfull = 0;

            for (int j = 0; j < n; ++j){
                --a[j];
                if (a[j] > 0){
                    curr[j] =  1;
                    cfull += j + 1;
                } else {
                    curr[j] = 0;
                }
            }
        } else {
            cout << 0;
        }
    }
}


#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    int a[n] = {0};
    int curr[n] = {0};
    int full = n * (n + 1) / 2;
    int cfull = 0;
    for (int i = 0; i < m; ++i){

        int d;
        cin >> d;
        ++a[d-1];

        if (curr[d-1] == 0){
            cfull += d;

        }
        curr[d-1] = 1;

        if (cfull == full){
            cout << 1;
            cfull = 0;

            for (int j = 0; j < n; ++j){
                --a[j];
                if (a[j] > 0){
                    curr[j] =  1;
                    cfull += i + 1;
                } else {
                    curr[j] = 0;
                }
            }
        } else {
            cout << 0;
        }
    }
}


#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    int a[n] = {0};
    int curr[n] = {0};
    int full = n * (n + 1) / 2;
    int cfull = 0;
    for (int i = 0; i < m; ++i){

        int d;
        cin >> d;
        ++a[d-1];

        if (curr[d-1] == 0){
            cfull += d;

        }
        curr[d-1] = 1;

        if (cfull == full){
            cout << 1;
            cfull = 0;

            for (int j = 0; j < n; ++j){
                --a[i];
                if (a[i] > 0){
                    curr[d-1] =  1;;
                    cfull += d;
                }
            }
        } else {
            cout << 0;
        }
    }
}


#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    int a[n] = {0};
    int curr[n] = {0};
    long long full = (long long)n * (long long)(n + 1) / 2;
    long long cfull = 0;
    for (int i = 0; i < m; ++i){

        int d;
        cin >> d;
        ++a[d-1];

        if (curr[d-1] == 0){
            cfull += d;

        }
        curr[d-1] = 1;

        if (cfull == full){
            cout << 1;
            cfull = 0;

            for (int j = 0; j < n; ++j){
                --a[j];
                if (a[j] > 0){
                    curr[j] =  1;
                    cfull += j + 1;
                } else {
                    curr[j] = 0;
                }
            }
        } else {
            cout << 0;
        }
    }
}


#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    int a[n] = {0};
    int curr = 0;
    int full = pow(2, n) - 1;
    for (int i = 0; i < m; ++i){

        int d;
        cin >> d;
        ++a[d-1];
        curr = curr | (1 << (d-1));

        if (curr == full){
            cout << 1;
            curr = 0;
            for (int j = 0; j < n; ++j){
                --a[i];
                if (a[i] > 0){
                    curr =  curr | (1 << (d-1));
                }
            }
        } else {
            cout << 0;
        }
    }
}


#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    int a[n] = {0};
    int curr[n] = {0};
    long long full = n * (n + 1) / 2;
    long long cfull = 0;
    for (int i = 0; i < m; ++i){

        int d;
        cin >> d;
        ++a[d-1];

        if (curr[d-1] == 0){
            cfull += d;

        }
        curr[d-1] = 1;

        if (cfull == full){
            cout << 1;
            cfull = 0;

            for (int j = 0; j < n; ++j){
                --a[j];
                if (a[j] > 0){
                    curr[j] =  1;
                    cfull += i + 1;
                } else {
                    curr[j] = 0;
                }
            }
        } else {
            cout << 0;
        }
    }
}


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

#define ll long long

ll n,m,l=0,r=0,s=0,w=0,g=0,z,x=0;

int main(){
	cin >> n >> m;
	bool	A[n+1];
	for(ll i= 1; i<=n; i++)
		A[i]=1;
	for(ll i= 1; i<=m; i++)
	{
		cin >> x ;
		if(A[x]==1)
		{
			s++;
			A[x]=0;
		}

		if(s == n)
		{
			cout<<1;
			s=0;
			for(ll j= 1; j<=n; j++)
			A[j]=1;

		}
		else
			cout<<0;

	}

return 0;
}


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

#define ll long long

ll n,m,l=0,r=0,s=0,w=0,g=0,z,x=0;

int main(){
	cin >> n >> m;
	ll	A[n+1];
	for(ll i= 1; i<=n; i++)
		A[i]=0;
	for(ll i= 1; i<=m; i++)
	{
		cin >> x ;
		if(A[x]==0)
		{
			s++;
			A[x]++;
		}

		if(s == n)
		{
			cout<<1;
			s=0;
			for(ll j= 1; j<=n; j++)
			A[j]--;

		}
		else
			cout<<0;

	}

return 0;
}


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

#define ll long long

ll n,m,l=0,r=0,s=0,w=0,g=0,z,x=0,h=0;

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

	cin >> n >> m;
	ll	A[n+1];
	memset(A,0,sizeof(A));
	for(ll i= 1; i<=m; i++)
	{
		cin >> x ;
		if(A[x]==0)
		{
			s++;

		}

			A[x]++;

		if(s == n)
		{
			cout<<1;
			s=0;

			for(ll j= 1; j<=n; j++)
			{
				A[j]--;
				if(A[j]!=0)
				{

					s++;
				}
			}
		}
		else
			cout<<0;

	}

return 0;
}


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

#define ll long long

ll n,m,l=0,r=0,s=0,w=0,g=0,z,x=0,h=0;

int main(){
	cin >> n >> m;
	ll	A[n+1];
	for(ll i= 1; i<=n; i++)
		A[i]=0;
	for(ll i= 1; i<=m; i++)
	{
		cin >> x ;
		if(A[x]==0)
		{
			s++;
			A[x]++;
		}
		else
		{

			h++;
			A[x]++;
		}

		if(s == n)
		{
			cout<<1;
			s=h;
			h=0;
			for(ll j= 1; j<=n; j++)
			A[j]--;

		}
		else
			cout<<0;

	}

return 0;
}


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

#define ll long long

ll n,m,l=0,r=0,s=0,w=0,g=0,z,x=0,h=0;

int main(){

    ios_base::sync_with_stdio(false); cin.tie(nullptr);

	cin >> n >> m;
	ll	A[n+1];
	for(ll i= 1; i<=n; i++)
		A[i]=0;
	for(ll i= 1; i<=m; i++)
	{
		cin >> x ;
		if(A[x]==0)
		{
			s++;

		}

			A[x]++;

		if(s == n)
		{
			cout<<1;
			s=0;

			for(ll j= 1; j<=n; j++)
			{
				A[j]--;
				if(A[j]!=0)
				{

					s++;
				}
			}
		}
		else
			cout<<0;

	}

return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[100000];
bool check(int n){
	for(int i=0;i<n;i++) if(a[i]==0) return false;
	return true;
}
int main(){
	int n,m;
	cin>>n>>m;
	int temp;
	for(int i=0;i<m;i++){
		cin>>temp;
		a[temp-1]++;
		//cout<<",a= "<<a<<" ";,a= <<a<<" "
		if(check(n)){
			cout<<"1";
			for(int i=0;i<n;i++) a[i]--;
		}else cout<<"0";
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[100009];
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	int temp,b=0;
	for(int i=0;i<m;i++){
		scanf("%d",&temp);
		if(a[temp]==0) b++;
		a[temp]++;
		//cout<<",a= "<<a<<" ";,a= <<a<<" "
		if(b==n){
			printf("1");
			for(int i=1;i<=n;i++){
				a[i]--;
				if(a[i]) b++;
			}
		}else printf("0");
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[100009];
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	int temp,b=0;
	for(int i=0;i<m;i++){
		scanf("%d",&temp);
		if(a[temp]==0) b++;
		a[temp]++;
		//cout<<",a= "<<a<<" ";,a= <<a<<" "
		if(b==n){
			printf("1");
			for(int i=1;i<=n;i++) a[i]--;
		}else printf("0");
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	int a;
	set<int> s;
	for(int i=0;i<m;i++){
		cin>>a;
		s.insert(a);
		//cout<<",a= "<<a<<" ";,a= <<a<<" "
		if(s.size()==n){
			cout<<"1";
			s.clear();
		}else cout<<"0";
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[100000];
bool check(int n){
	for(int i=0;i<n;i++) if(a[i]==0) return false;
	for(int i=0;i<n;i++) a[i]--;
	return true;
}
int main(){
	int n,m;
	cin>> n>> m;
	int temp;
	for(int i=0;i<m;i++){
		cin>>temp;
		a[temp-1]++;
		//cout<<",a= "<<a<<" ";,a= <<a<<" "
		if(check(n)){
			printf("%c",'1');
		}else printf("%c",'0');
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[100000];
bool check(int n){
	for(int i=0;i<n;i++) if(a[i]==0) return false;
	for(int i=0;i<n;i++) a[i]--;
	return true;
}
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	int temp;
	for(int i=0;i<m;i++){
		scanf("%d",temp);
		a[temp-1]++;
		//cout<<",a= "<<a<<" ";,a= <<a<<" "
		if(check(n)){
			printf("1");
		}else printf("0");
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[100000];
bool check(int n){
	for(int i=0;i<n;i++) if(a[i]==0) return false;
	for(int i=0;i<n;i++) a[i]--;
	return true;
}
int main(){
	int n,m;
	scanf("%d,%d",n,m);
	int temp;
	for(int i=0;i<m;i++){
		scanf("%d",temp);
		a[temp-1]++;
		//cout<<",a= "<<a<<" ";,a= <<a<<" "
		if(check(n)){
			printf("%c",'1');
		}else printf("%c",'0');
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[100009];
bool check(int n){
	for(int i=1;i<=n;i++) if(!a[i]) return false;
	for(int i=1;i<=n;i++) a[i]--;
	return true;
}
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	int temp;
	for(int i=0;i<m;i++){
		scanf("%d",&temp);
		a[temp]++;
		//cout<<",a= "<<a<<" ";,a= <<a<<" "
		if(check(n)){
			printf("1");
		}else printf("0");
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[100009];
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	int temp,b=0;
	for(int i=0;i<m;i++){
		scanf("%d",&temp);
		if(a[temp]==0) b++;//printf("b= %d ",b);
		a[temp]++;
		//printf("temp= %d ",temp);//,a= <<a<<" "
		if(b==n){
			b=0;
			printf("1");
			for(int i=1;i<=n;i++){
				a[i]--;
				if(a[i]) b++;
			}
		}else printf("0");
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[100000];
bool check(int n){
	for(int i=0;i<n;i++) if(a[i]==0) return false;
	return true;
}
int main(){
	int n,m;
	cin>>n>>m;
	int temp;
	for(int i=0;i<m;i++){
		cin>>temp;
		a[temp]++;
		//cout<<",a= "<<a<<" ";,a= <<a<<" "
		if(check(n)){
			cout<<"1";
			for(int i=0;i<n;i++) a[i]--;
		}else cout<<"0";
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[100000];
bool check(int n){
	for(int i=0;i<n;i++) if(a[i]==0) return false;
	for(int i=0;i<n;i++) a[i]--;
	return true;
}
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	int temp;
	for(int i=0;i<m;i++){
		scanf("%d",&temp);
		a[temp-1]++;
		//cout<<",a= "<<a<<" ";,a= <<a<<" "
		if(check(n)){
			printf("1");
		}else printf("0");
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[100000];
bool check(int n){
	for(int i=0;i<n;i++) if(a[i]==0) return false;
	for(int i=0;i<n;i++) a[i]--;
	return true;
}
int main(){
	int n,m;
	cin>>n>>m;
	int temp;
	for(int i=0;i<m;i++){
		scanf("%d",temp);
		a[temp-1]++;
		//cout<<",a= "<<a<<" ";,a= <<a<<" "
		if(check(n)){
			printf("%c",'1');
		}else printf("%c",'0');
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[100000];
bool check(int n){
	for(int i=0;i<n;i++) if(a[i]==0) return false;
	for(int i=0;i<n;i++) a[i]--;
	return true;
}
int main(){
	int n,m;
	cin>>n>>m;
	int temp;
	for(int i=0;i<m;i++){
		cin>>temp;
		a[temp-1]++;
		//cout<<",a= "<<a<<" ";,a= <<a<<" "
		if(check(n)){
			cout<<"1";
		}else cout<<"0";
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	int a;
	set<int> s;
	for(int i=0;i<m;i++){
		cin>>a;
		s.insert(a);
		if(s.size()==n){
			cout<<"1";
			s.clear();
		}else cout<<"0";
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	int a;
	set<int> s;
	for(int i=0;i<m;i++){
		cin>>a;
		s.insert(a);
		if(s.size()==n){
			cout<<"1";
			s.clear();
		}
		cout<<0;
	}
	return 0;
}


#include <iostream>
#include <algorithm>
#include <string.h>
using namespace std;
int main()
{
    int n,i,m,j,k,l,p,b[1000],a[1000],flag;
    cin>>n>>m;
    memset(b,0,sizeof(b));
    for(i=0; i<m; i++)
        cin>>a[i];
    k=0;
    l=0;
    for(i=l; i<m; i++)
    {
        flag=0;
        for(j=l; j<i; j++)
        {
            if(a[j]==a[i])
            {
                flag=1;
                break;
            }
        }
        if(j==i&&flag==0)
            k++;
        if(k==n)
        {
            k=0;
            b[i]=1;
            l=i+1;
        }
    }
    for(i=0; i<m; i++)
        cout<<b[i];
    return 0;
}


#include <iostream>
#include <algorithm>
#include <string.h>
#include <map>
using namespace std;
int main()
{
    int n,i,m,k,j,d,c[100005],a[100005],flag,b[100005];
    cin>>n>>m;
    map<int,int>q;
    memset(c,0,sizeof(c));
    memset(b,0,sizeof(b));
    for(i=1; i<=m; i++)
        cin>>a[i];
    for(i=1; i<=m; i++)
    {
        q[a[i]]++;
        if(q.size()==n)
        {
            c[i]=1;
            for(j=1; j<=n; j++)
            {
                if(q[j]==1)
                    q.erase(j);
                else
                    q[j]--;
            }
        }
        else
            c[i]=0;
    }
    for(i=1; i<=m; i++)
        cout<<c[i];
    return 0;
}


#include <iostream>
#include <algorithm>
#include <string.h>
using namespace std;
int main()
{
    int n,i,m,l,j,d,c[1000],a[1000],flag,b[1000];
    cin>>n>>m;
    memset(c,0,sizeof(c));
    memset(b,0,sizeof(b));
    for(i=0; i<m; i++)
        cin>>a[i];
    l=0;
    for(i=l; i<m; i++)
    {
        d=a[i];
        b[d]++;
        flag=0;
        for(j=1; j<=n; j++)
        {
            if(b[j]==0)
            {
                flag=1;
                break;
            }
        }
        if(j==n+1&&flag==0)
        {
            c[i]=1;
            l=i+1;
            for(j=1; j<=n; j++)
                b[j]--;
        }
    }
    for(i=0; i<m; i++)
        cout<<c[i];
    return 0;
}


#include <iostream>
#include <algorithm>
#include <string.h>
using namespace std;
int main()
{
    int n,i,m,l,j,d,c[100005],a[100005],flag,b[100005];
    cin>>n>>m;
    memset(c,0,sizeof(c));
    memset(b,0,sizeof(b));
    for(i=0; i<m; i++)
        cin>>a[i];
    l=0;
    for(i=l; i<m; i++)
    {
        d=a[i];
        b[d]++;
        flag=0;
        for(j=1; j<=n; j++)
        {
            if(b[j]==0)
            {
                flag=1;
                break;
            }
        }
        if(j==n+1&&flag==0)
        {
            c[i]=1;
            l=i+1;
            for(j=1; j<=n; j++)
                b[j]--;
        }
    }
    for(i=0; i<m; i++)
        cout<<c[i];
    return 0;
}


#include <iostream>
#include <algorithm>
#include <string.h>
using namespace std;
int main()
{
    int n,i,m,k,j,d,c[100005],a[100005],flag,b[100005];
    cin>>n>>m;k=0;
    memset(c,0,sizeof(c));
    memset(b,0,sizeof(b));
    for(i=1; i<=m; i++)
        cin>>a[i];
    for(i=1; i<=m; i++)
    {
        d=a[i];
        if(b[d]==0)
            k++;
        b[d]++;
        if(k==n)
        {
            k=0;
            c[i]=1;
            for(j=1; j<=n; j++)
            {
                b[j]--;
                if(b[j]>0)
                    k++;
            }
        }
        else
            c[i]=0;
    }
    for(i=1; i<=m; i++)
        cout<<c[i];
    return 0;
}


#include <iostream>
#include <algorithm>
#include <string.h>
using namespace std;
int main()
{
    int n,i,m,k,j,d,c[100005],a[100005],flag,b[100005];
    cin>>n>>m;
    memset(c,0,sizeof(c));
    memset(b,0,sizeof(b));
    for(i=1; i<=m; i++)
        cin>>a[i];
    for(i=1; i<=m; i++)
    {
        d=a[i];
        if(b[d]==0)
            k++;
        b[d]++;
        if(k==n)
        {
            k=0;
            c[i]=1;
            for(j=1; j<=n; j++)
            {
                b[j]--;
                if(b[j]>0)
                    k++;
            }
        }
    }
    for(i=1; i<=m; i++)
        cout<<c[i];
    return 0;
}


#include <iostream>
#include <algorithm>
#include <string.h>
using namespace std;
int main()
{
    int n,i,m,l,j,d,c[1000],a[1000],flag,b[1000];
    cin>>n>>m;
    memset(c,0,sizeof(c));
    memset(b,0,sizeof(b));
    for(i=0; i<m; i++)
        cin>>a[i];
    l=0;
    for(i=l; i<m; i++)
    {
        d=a[i];
        b[d]++;
        flag=0;
        for(j=1; j<=n; j++)
        {
            if(b[j]==0)
            {
                flag=1;
                break;
            }
        }
        if(j==n+1&&flag==0)
        {
            c[i]=1;
            l=i+1;
            for(j=0; j<n; j++)
                b[j]--;
        }
    }
    for(i=0; i<m; i++)
        cout<<c[i];
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<db,db> pdb;

typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<db> vd;
typedef vector<string> vs;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<pdb> vpd;

#define mp make_pair
#define ff first
#define ss second
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define rall(x) (x).rbegin(), (x).rend()
#define ins insert
#define ft front()
#define bk back()
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define vv <vector<vector> >
#define mp make_pair
#define str(a, b) substr((a), (b))
#define rr return
#define r0 return 0
#define mi map<int>
#define ms map<string>
#define ml map<ll>
#define all_sum(a,b) accumulate((a),(b),0)
#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)
void adskiy_razgon(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
const int MOD = 1e9+7; // 888244353;
const int MX = 2e5+5;
const ll INF = 1e18;
const ld PI = acos((ld)-1);
const int xd[4] = {1,0,-1,0}, yd[4] = {0,1,0,-1};
ll nod(ll a, ll b) {
    if(b > a) {
        swap(a, b);
    }
    while(b > 0) {
        a %= b;
        swap(a, b);
    }
    return a;
}
ll nok(ll a,ll b) {
    return a * b / nod(a, b);
}
void sp(ll a,double b) {
    cout << fixed << setprecision(a) << b;
}
ll binpow (ll a, ll n) {
    if (n == 0) {
        return 1;
    }
    if (n % 2 == 1) {
        return binpow (a, n - 1) * a;
    }
    else {
        ll b = binpow (a, n / 2);
        return b * b;
    }
}

template<class A> void read(vector<A>& v);
template<class A, size_t S> void read(array<A, S>& a);
template<class T> void read(T& x) {
    cin >> x;
}
void read(double& d) {
    string t;
    read(t);
    d=stod(t);
}
void read(long double& d) {
    string t;
    read(t);
    d=stold(t);
}
template<class H, class... T> void read(H& h, T&... t) {
    read(h);
	read(t...);
}
template<class A> void read(vector<A>& x) {
    EACH(a, x)
        read(a);
}
template<class A, size_t S> void read(array<A, S>& x) {
    EACH(a, x)
        read(a);
}
string to_string(char c) {
    return string(1, c);
}
string to_string(bool b) {
    return b?"true":"false";
}
string to_string(const char* s) {
    return string(s);
}
string to_string(string s) {
    return s;
}
string to_string(vector<bool> v) {
    string res;
	FOR(sz(v))
        res+=char('0'+v[i]);
    return res;
}

template<size_t S> string to_string(bitset<S> b) {
    string res;
	FOR(S)
        res+=char('0'+b[i]);
    return res;
}
template<class T> string to_string(T v) {
    bool f=1;
    string res;
    EACH(x, v) {
        if(!f)
            res+=' ';
        f=0;
        res+=to_string(x);
    }
    return res;
}
template<class A> void write(A x) {
    cout << to_string(x);
}
template<class H, class... T> void write(const H& h, const T&... t) {
    write(h);
    write(t...);
}
void print() {
     write("\n");
}
template<class H, class... T> void print(const H& h, const T&... t) {
    write(h);
    if(sizeof...(t))
        write(' ');
    print(t...);
}

void yes(bool ok) {
    print((ok ? "YES" : "Yes"));
}
void no(bool ok) {
    print((ok ? "NO" : "No"));

}
/*
⣿⣿⣿⣿⣿⣿⡷⣯⢿⣿⣷⣻⢯⣿⡽⣻⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣇⠸⣿⣿⣆⠹⣿⣿⢾⣟⣯⣿⣿⣿⣿⣿⣿⣽⣻⣿⣿⣿⣿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣻⣽⡿⣿⣎⠙⣿⣞⣷⡌⢻⣟⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣿⣿⣿⣿⣿⣿⡄⠹⣿⣿⡆⠻⣿⣟⣯⡿⣽⡿⣿⣿⣿⣿⣽⡷⣯⣿⣿⣿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣟⣷⣿⣿⣿⡀⠹⣟⣾⣟⣆⠹⣯⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⢠⡘⣿⣿⡄⠉⢿⣿⣽⡷⣿⣻⣿⣿⣿⣿⡝⣷⣯⢿⣿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣯⢿⣾⢿⣿⡄⢄⠘⢿⣞⡿⣧⡈⢷⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⢸⣧⠘⣿⣷⠈⣦⠙⢿⣽⣷⣻⣽⣿⣿⣿⣿⣌⢿⣯⢿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣟⣯⣿⢿⣿⡆⢸⡷⡈⢻⡽⣷⡷⡄⠻⣽⣿⣿⡿⣿⣿⣿⣿⣿⣿⣷⣿⣿⣿⣿⣏⢰⣯⢷⠈⣿⡆⢹⢷⡌⠻⡾⢋⣱⣯⣿⣿⣿⣿⡆⢻⡿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⡎⣿⢾⡿⣿⡆⢸⣽⢻⣄⠹⣷⣟⣿⣄⠹⣟⣿⣿⣟⣿⣿⣿⣿⣿⣿⣽⣿⣿⣿⡇⢸⣯⣟⣧⠘⣷⠈⡯⠛⢀⡐⢾⣟⣷⣻⣿⣿⣿⡿⡌⢿⣻⣿⣿
⣿⣿⣿⣿⣿⣿⣧⢸⡿⣟⣿⡇⢸⣯⣟⣮⢧⡈⢿⣞⡿⣦⠘⠏⣹⣿⣽⢿⣿⣿⣿⣿⣯⣿⣿⣿⡇⢸⣿⣿⣾⡆⠹⢀⣠⣾⣟⣷⡈⢿⣞⣯⢿⣿⣿⣿⢷⠘⣯⣿⣿
⣿⣿⣿⣿⣿⣿⣿⡈⣿⢿⣽⡇⠘⠛⠛⠛⠓⠓⠈⠛⠛⠟⠇⢀⢿⣻⣿⣯⢿⣿⣿⣿⣷⢿⣿⣿⠁⣾⣿⣿⣿⣧⡄⠇⣹⣿⣾⣯⣿⡄⠻⣽⣯⢿⣻⣿⣿⡇⢹⣾⣿
⣿⣿⣿⣿⣿⣿⣿⡇⢹⣿⡽⡇⢸⣿⣿⣿⣿⣿⣞⣆⠰⣶⣶⡄⢀⢻⡿⣯⣿⡽⣿⣿⣿⢯⣟⡿⢀⣿⣿⣿⣿⣿⣧⠐⣸⣿⣿⣷⣿⣿⣆⠹⣯⣿⣻⣿⣿⣿⢀⣿⢿
⣿⣿⣿⣿⣿⣿⣿⣿⠘⣯⡿⡇⢸⣿⣿⣿⣿⣿⣿⣿⣧⡈⢿⣳⠘⡄⠻⣿⢾⣽⣟⡿⣿⢯⣿⡇⢸⣿⣿⣿⣿⣿⣿⡀⢾⣿⣿⣿⣿⣿⣿⣆⠹⣾⣷⣻⣿⡿⡇⢸⣿
⣿⣿⣿⣿⣿⣿⣿⣿⡇⢹⣿⠇⢸⣿⣿⣿⣿⣿⣿⣿⣿⣷⣄⠻⡇⢹⣆⠹⣟⣾⣽⣻⣟⣿⣽⠁⣾⣿⣿⣿⣿⣿⣿⣇⣿⣿⠿⠛⠛⠉⠙⠋⢀⠁⢘⣯⣿⣿⣧⠘⣿
⣿⣿⣿⣿⣿⣿⣿⣿⣿⡈⣿⡃⢼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⡙⠌⣿⣆⠘⣿⣞⡿⣞⡿⡞⢠⣿⣿⣿⣿⣿⡿⠛⠉⠁⢀⣀⣠⣤⣤⣶⣶⣶⡆⢻⣽⣞⡿⣷⠈⣿
⣿⣿⣿⣿⣿⣿⣿⣿⡿⠃⠘⠁⠉⠉⠉⠉⠉⠉⠉⠉⠉⠙⠛⠛⢿⣄⢻⣿⣧⠘⢯⣟⡿⣽⠁⣾⣿⣿⣿⣿⣿⡃⢀⢀⠘⠛⠿⢿⣻⣟⣯⣽⣻⣵⡀⢿⣯⣟⣿⢀⣿
⣿⣿⣿⣟⣿⣿⣿⣿⣶⣶⡆⢀⣿⣾⣿⣾⣷⣿⣶⠿⠚⠉⢀⢀⣤⣿⣷⣿⣿⣷⡈⢿⣻⢃⣼⣿⣿⣿⣿⣻⣿⣿⣿⡶⣦⣤⣄⣀⡀⠉⠛⠛⠷⣯⣳⠈⣾⡽⣾⢀⣿
⣿⢿⣿⣿⣻⣿⣿⣿⣿⣿⡿⠐⣿⣿⣿⣿⠿⠋⠁⢀⢀⣤⣾⣿⣿⣿⣿⣿⣿⣿⣿⣌⣥⣾⡿⣿⣿⣷⣿⣿⢿⣷⣿⣿⣟⣾⣽⣳⢯⣟⣶⣦⣤⡾⣟⣦⠘⣿⢾⡁⢺
⣿⣻⣿⣿⡷⣿⣿⣿⣿⣿⡗⣦⠸⡿⠋⠁⢀⢀⣠⣴⢿⣿⣽⣻⢽⣾⣟⣷⣿⣟⣿⣿⣿⣳⠿⣵⣧⣼⣿⣿⣿⣿⣿⣾⣿⣿⣿⣿⣿⣽⣳⣯⣿⣿⣿⣽⢀⢷⣻⠄⠘
⣿⢷⣻⣿⣿⣷⣻⣿⣿⣿⡷⠛⣁⢀⣀⣤⣶⣿⣛⡿⣿⣮⣽⡻⣿⣮⣽⣻⢯⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣯⢀⢸⣿⢀⡆
⠸⣟⣯⣿⣿⣷⢿⣽⣿⣿⣷⣿⣷⣆⠹⣿⣶⣯⠿⣿⣶⣟⣻⢿⣷⣽⣻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⢀⣯⣟⢀⡇
⣇⠹⣟⣾⣻⣿⣿⢾⡽⣿⣿⣿⣿⣿⣆⢹⣶⣿⣻⣷⣯⣟⣿⣿⣽⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⢀⡿⡇⢸⡇
⣿⣆⠹⣷⡻⣽⣿⣯⢿⣽⣻⣿⣿⣿⣿⣆⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠛⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠇⢸⣿⠇⣼⡇
⡙⠾⣆⠹⣿⣦⠛⣿⢯⣷⢿⡽⣿⣿⣿⣿⣆⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠃⠎⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠏⢀⣿⣾⣣⡿⡇
⣿⣷⡌⢦⠙⣿⣿⣌⠻⣽⢯⣿⣽⣻⣿⣿⣿⣧⠩⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡏⢰⢣⠘⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠃⢀⢀⢿⣞⣷⢿⡇
⣿⣽⣆⠹⣧⠘⣿⣿⡷⣌⠙⢷⣯⡷⣟⣿⣿⣿⣷⡀⡹⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣈⠃⣸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⢀⣴⡧⢀⠸⣿⡽⣿⢀
⢻⣽⣿⡄⢻⣷⡈⢿⣿⣿⢧⢀⠙⢿⣻⡾⣽⣻⣿⣿⣄⠌⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠛⢁⣰⣾⣟⡿⢀⡄⢿⣟⣿⢀
⡄⢿⣿⣷⢀⠹⣟⣆⠻⣿⣿⣆⢀⣀⠉⠻⣿⡽⣯⣿⣿⣷⣈⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠋⢀⣠⠘⣯⣷⣿⡟⢀⢆⠸⣿⡟⢸
⣷⡈⢿⣿⣇⢱⡘⢿⣷⣬⣙⠿⣧⠘⣆⢀⠈⠻⣷⣟⣾⢿⣿⣆⠹⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠋⣠⡞⢡⣿⢀⣿⣿⣿⠇⡄⢸⡄⢻⡇⣼
⣿⣷⡈⢿⣿⡆⢣⡀⠙⢾⣟⣿⣿⣷⡈⠂⠘⣦⡈⠿⣯⣿⢾⣿⣆⠙⠻⠿⠿⠿⠿⡿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠛⢋⣠⣾⡟⢠⣿⣿⢀⣿⣿⡟⢠⣿⢈⣧⠘⢠⣿
⣿⣿⣿⣄⠻⣿⡄⢳⡄⢆⡙⠾⣽⣿⣿⣆⡀⢹⡷⣄⠙⢿⣿⡾⣿⣆⢀⡀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⣀⣠⣴⡿⣯⠏⣠⣿⣿⡏⢸⣿⡿⢁⣿⣿⢀⣿⠆⢸⣿
⣿⣿⣿⣿⣦⡙⣿⣆⢻⡌⢿⣶⢤⣉⣙⣿⣷⡀⠙⠽⠷⠄⠹⣿⣟⣿⣆⢙⣋⣤⣤⣤⣄⣀⢀⢀⢀⢀⣾⣿⣟⡷⣯⡿⢃⣼⣿⣿⣿⠇⣼⡟⣡⣿⣿⣿⢀⡿⢠⠈⣿
⣿⣿⣿⣿⣿⣷⣮⣿⣿⣿⡌⠁⢤⣤⣤⣤⣬⣭⣴⣶⣶⣶⣆⠈⢻⣿⣿⣆⢻⣿⣿⣿⣿⣿⣿⣷⣶⣤⣌⣉⡘⠛⠻⠶⣿⣿⣿⣿⡟⣰⣫⣴⣿⣿⣿⣿⠄⣷⣿⣿⣿
*/

int a[100000];
vi v[100000];
void solve() {
    int n, m;
    read(n, m);
    string s;
    FOR(m) {
        s += '0';
        read(a[i]);
        v[a[i]].pb(i);
    }
    FOR(m + 1) {
        int mx = 0;
        FOR(n) {
            if(v[i + 1].empty()) {
                print(s);
                rr;
            }
            mx = max(mx, v[i + 1][0]);
            v[i + 1].erase(v[i + 1].begin());
        }
        s[mx] = '1';
    }
    print(s);
}
int main(){
    adskiy_razgon();
    ll t = 1;
    //cin >> t;
    for(int i = 1; i <= t; ++i) {
        //cout << "Case #" << i << ": ";
        solve();
    }
    r0;
}