p,q,r=14,d,m;main(t,n){for(scanf("%d",&d);~t;n-10?n-111?t%3<1?m=r>d?fmax(d+fmax(p,q),m):fmax(m,p+q+r),p=q,q=0,r=1:r++:q++,t=n:0)n=getchar();m=!printf("%d",p+d>m?p+d:m);}