//#define LOCAL
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace _258_E
{
    class Program
    {
        class Files
        {
            StreamReader fin = new StreamReader("d:\\date.in");
            StreamWriter fout = new StreamWriter("d:\\date.out");
            public string ReadLine()
            {
                return fin.ReadLine();
            }
            public void Write(string s)
            {
                fout.Write(s);
            }
            public void WriteLine(string s)
            {
                fout.WriteLine(s);
            }
            public void Close()
            {
                fout.Close();
            }
        }
        #if LOCAL
            static Files Console = new Files();
        #endif
        const Int64 Mod = (Int64)1e9+7;
        static string[] s;
        static string Line;
        static int step = 0, Length = 0;
        static Int64 GetNext()
        {
            if (step == Length)
            {
                Line = Console.ReadLine();
                s = Line.Split(' ');
                Length = s.Length;
                step = 0;
            }
            ++step;
            return Int64.Parse(s[step - 1]);
        }
        static Int64[] a = new Int64[30];
        static Int64 Inv = 1;
        static Int64 Comb(Int64 n, Int64 k)
        {
            if (n < k)
                return 0;
            Int64 result = 1;
            for (Int64 i = n - k + 1; i <= n; ++i)
                result = (Int64)result*i%Mod;
            result = (Int64)result*Inv%Mod;
            return result;
        }
        static Int64 Fix(Int64 x)
        {
            Int64 ret = x;
            while(ret >= Mod)
                ret -= Mod;
            while(ret < 0)
                ret += Mod;
            return ret;
        }

        static Int64 Pow_Log(Int64 x,Int64 p)
        {
            if (p == 0)
                return 1;
            Int64 y;
            if(p%2==1)
               y = (Int64)Pow_Log(x,p-1)*x%Mod;
            else
            {
                y = Pow_Log(x,p/2);
                y = (Int64)y*y%Mod;
            }
            return y;
        }
        static void Main(string[] args)
        {
            Int64 n = GetNext(), S = GetNext(), sum = 0, Max = 1;
            Inv = 1;
            for (int i = 0; i < n; ++i)
            {
                Max *= 2;
                if (i > 0)
                    Inv *= i;
                a[i] = GetNext();
                sum += a[i];
            }
            if (sum < S)
            {
                Console.WriteLine("0");
                return;
            }
            Inv = Pow_Log(Inv, Mod - 2);
            Int64 Solution = Comb(S + n - 1, n - 1),cnt = 0;
            for (int i = 1; i < Max; ++i)
            {
                Int64 k = 0;
                int nr = 0;
                for (int j = 0; j < n; ++j)
                    if (((1 << j) & i) != 0)
                    {
                        ++nr;
                        k += a[j]+1;
                    }
                k = S - k;
                if (nr % 2 == 1)
                    cnt += Comb(k + n - 1, n - 1);
                else
                    cnt -= Comb(k + n - 1, n - 1);
                cnt = Fix(cnt);
            }
            Solution -= cnt;
            Solution = Fix(Solution);
            Console.WriteLine(Solution.ToString());
            #if LOCAL
                Console.Close();
            #endif
        }
    }
}


#define LOCAL
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace _258_E
{
    class Program
    {
        class Files
        {
            StreamReader fin = new StreamReader("d:\\date.in");
            StreamWriter fout = new StreamWriter("d:\\date.out");
            public string ReadLine()
            {
                return fin.ReadLine();
            }
            public void Write(string s)
            {
                fout.Write(s);
            }
            public void WriteLine(string s)
            {
                fout.WriteLine(s);
            }
            public void Close()
            {
                fout.Close();
            }
        }
        #if LOCAL
            static Files Console = new Files();
        #endif
        const int Mod = (int)1e9+7;
        static string[] s;
        static string Line;
        static int step = 0, Length = 0;
        static Int64 GetNext()
        {
            if (step == Length)
            {
                Line = Console.ReadLine();
                s = Line.Split(' ');
                Length = s.Length;
                step = 0;
            }
            ++step;
            return Int64.Parse(s[step - 1]);
        }
        static Int64[] a = new Int64[30];
        static Int64 Inv = 1;
        static Int64 Comb(Int64 n, Int64 k)
        {
            if (n < k)
                return 0;
            Int64 result = 1;
            for (Int64 i = n - k + 1; i <= n; ++i)
                result = (Int64)result*i%Mod;
            result = (Int64)result*Inv%Mod;
            return result;
        }
        static Int64 Fix(Int64 x)
        {
            Int64 ret = x;
            if (ret >= Mod)
                ret -= Mod;
            if (ret < 0)
                ret += Mod;
            return ret;
        }

        static Int64 Pow_Log(Int64 x,Int64 p)
        {
            if (p == 0)
                return 1;
            Int64 y;
            if(p%2==1)
               y = (Int64)Pow_Log(x,p-1)*x%Mod;
            else
            {
                y = Pow_Log(x,p/2);
                y = (Int64)y*y%Mod;
            }
            return y;
        }
        static void Main(string[] args)
        {
            Int64 n = GetNext(), S = GetNext(), sum = 0, Max = 1;
            Inv = 1;
            for (int i = 0; i < n; ++i)
            {
                Max *= 2;
                if (i > 0)
                    Inv *= i;
                a[i] = GetNext();
                sum += a[i];
            }
            if (sum < S)
            {
                Console.WriteLine("0");
                return;
            }
            Inv = Pow_Log(Inv, Mod - 2);
            Int64 Solution = Comb(S + n - 1, n - 1),cnt = 0;
            for (int i = 1; i < Max; ++i)
            {
                Int64 k = 0;
                int nr = 0;
                for (int j = 0; j < n; ++j)
                    if (((1 << j) & i) != 0)
                    {
                        ++nr;
                        k += a[j]+1;
                    }
                k = S - k;
                if (nr % 2 == 1)
                    cnt += Comb(k + n - 1, n - 1);
                else
                    cnt -= Comb(k + n - 1, n - 1);
                cnt = Fix(cnt);
            }
            Solution -= cnt;
            Console.WriteLine(Solution.ToString());
            #if LOCAL
                Console.Close();
            #endif
        }
    }
}


using System; using System.Linq;

class P {
  static void Main() {
    var s = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
    var a = s[0]; var n = s[1];
    var digits = Enumerable.Repeat(0,0).ToList();
    while (a > 0 && n > 0) {
      var d = (int)((n%3 + 3 - a%3) % 3);
      digits.Add(d);
    }
    var res = digits.Aggregate(0, (acc,x) => acc*3+x);
    Console.Write(res);
  }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;

namespace ConsoleApplication2
{

    class Program
    {

        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            long a = long.Parse(str[0]);
            long c = long.Parse(str[1]);

            int length = (int)Math.Max(Math.Ceiling(Math.Log(a, 3)), Math.Ceiling(Math.Log(c, 3)))+1;

            //Console.WriteLine(length);

            int[] astr = new int[length];
            for (int i = 0; i < length; i++ )
            {
                astr[i] = (int)((a / (int)Math.Pow(3, i)) % 3);
            }

            int[] cstr = new int[length];
            for (int i = 0; i < length; i++)
            {
                cstr[i] = (int)((c / (int)Math.Pow(3, i)) % 3);
            }

            int[] bstr = new int[length];
            for (int i = 0; i < length; i++)
            {
                if (astr[i] <= cstr[i])
                {
                    bstr[i] = cstr[i] - astr[i];
                }
                else
                {
                    bstr[i] = cstr[i] - astr[i] + 3;
                }
            }

            /*
            for (int i = 0; i < length; i++ )
            {
                Console.Write(astr[i]);
            }
            Console.WriteLine();

            for (int i = 0; i < length; i++)
            {
                Console.Write(bstr[i]);
            }
            Console.WriteLine();

            for (int i = 0; i < length; i++)
            {
                Console.Write(cstr[i]);
            }
            Console.WriteLine();
            */

            long res = 0;
            for (int i = 0; i < length; i++)
            {
                //Console.WriteLine(bstr[i] + "  " + (int)Math.Pow(3, i));
                res += bstr[i] * (long)Math.Pow(3, i);
            }
            Console.WriteLine(res);
        }

    }
}


using System;
using System.IO;
using System.Text;

namespace Pyramid_of_Glasses
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            int n = Next();
            int t = Next();

            var nn = new int[n,n];
            int d = 1;
            nn[0, 0] = 1;
            for (int i = 1; i < n; i++)
            {
                d *= 2;
                nn[0, i] = nn[0, i - 1] + d;
            }

            d = 1;
            for (int i = 1; i < n; i++)
            {
                d *= 2;
                for (int j = 0; j < n; j++)
                {
                    nn[i, j] = nn[i - 1, j] + d;
                }
            }

            int count = 0;
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    if (i + j > n)
                        break;
                    if (nn[i, j] <= t)
                        count++;
                }
            }

            writer.WriteLine(count);
            writer.Flush();
        }

        private static int Next()
        {
            int c;
            int res = 0;
            do
            {
                c = reader.Read();
                if (c == -1)
                    return res;
            } while (c < '0' || c > '9');
            res = c - '0';
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return res;
                res *= 10;
                res += c - '0';
            }
        }
    }
}


using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Globalization;

namespace CodeForces
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			int[] nums = Console.ReadLine ().Split (' ').Select (int.Parse).ToArray ();
			int n = nums [0];
			int t = nums [1];
			double[,] triangle = new double[n, n];
			for (int k = 0; k < t; k++) {
				triangle [0, 0] += 1;
				for (int col = 0; col < n; col++) {
					for (int row = 0; row <= col; row++) {
						if (triangle [col, row] > 1) {
							double diff = triangle [col, row] - 1;
							triangle [col, row] = 1;
							triangle [col + 1, row] += diff / 2;
							triangle [col + 1, row + 1] += diff / 2;
						}
					}
				}
			}
			int count = 0;
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					if (triangle [i, j] == 1)
						count++;
				}
			}
			Console.WriteLine (count);
		}
	}
}


using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            char maxC = 'a';
            int maxKol = 0;
            for (int i=0;i<s.Length;i++)
            {
                if (maxC<s[i])
                {
                    maxC = s[i];
                    maxKol = 0;
                }
                else
                {
                    if (maxC == s[i])
                        maxKol++;
                }
            }
            string res = new string(maxC, maxKol+1);
            Console.WriteLine(res);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Main
{
    class Program
    {
        static void Main(string[] args)
        {
        }
    }
}


using System;

namespace CSharp
{
    public class _832A
    {
        public static void Main(string[] args)
        {
            string[] tokens = Console.ReadLine().Split();

            int n = int.Parse(tokens[0]);
            int k = int.Parse(tokens[1]);

            Console.WriteLine(n % (2 * k) >= k ? "YES" : "NO");
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] buffer = Console.ReadLine().Split(' ');
            int a = int.Parse(buffer[0]);
            int b = int.Parse(buffer[1]);
            int summ = 0;
            for (int i = 1; i <= a; i++)
            {
                for (int j = 1; j <= b; j++)
                {
                    if ((i + j) % 5 == 0)
                    {
                        summ++;
                    }
                }
            }
            Console.WriteLine(summ);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] buffer = Console.ReadLine().Split(' ');
            int a = int.Parse(buffer[0]);
            int b = int.Parse(buffer[1]);
            int index = b / 5;
            BigInteger summ = a * index;
            for (int i = 1; i <= a; i++)
            {
                for (int j = (5*index)+1; j <= b; j++)
                {
                    if ((i + j) % 5 == 0)
                    {
                        summ++;
                    }
                }
            }
            Console.WriteLine(summ);
        }
    }
}


using System;
using System.Linq;
namespace Alyona_and_Numbers
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int max = input.Max(),
                min = input.Min();
            int pairsCount = 0;
            for (int i = 1; i <= min; i++)
            {
                int intial = 5;
                int j = 1;
                while (true)
                {
                    int subtract = intial - i;
                    if(subtract<=0)
                    {
                        j++;
                        intial = 5 * j;
                        continue;
                    }
                    if (subtract <= max)
                    {
                        //Console.WriteLine($"({i},{subtract})");
                        pairsCount++;
                        j++;
                        intial =5*j;
                    }
                    else
                    {
                        break;
                    }
                }
            }
            Console.WriteLine(pairsCount);
        }
    }
}


using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){

		bool[] used = new bool[N];
		var SH = new SkewHeap<Pair>();
		used[0] = true;
		for(int j=1;j<N;j++){
			SH.Push(new Pair(j,(0+1+j+1)%(N+1)));
		}
		int vis = 1;
		long min = 0;
		while(SH.Count>0){
			var p = SH.Top; SH.Pop();
			int now = p.Pos;
			long cost = p.Cost;
			if(used[now]) continue;
			min += cost;
			used[now] = true;
			vis++;
			if(vis == N) break;
			for(int j=0;j<N;j++){
				if(used[j]) continue;
				if(j == now) continue;
				SH.Push(new Pair(j,(now+1+j+1)%(N+1)));
			}
		}

		Console.WriteLine(min);

	}
	int N;
	public Sol(){
		N = ri();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}

class Pair : IComparable<Pair> {
	public int Pos;
	public long Cost;
	public Pair(int p, long c) {
		Pos = p; Cost = c;
	}
	public int CompareTo(Pair t) {
		//return this.Cost > t.Cost ? -1 : this.Cost < t.Cost ? 1 : 0;
		return this.Cost > t.Cost ? 1 : this.Cost < t.Cost ? -1 : 0;
	}
}

class SkewHeap<T> where T:IComparable<T>{
	public int Count{
		get{return cnt;}
		private set{cnt=value;}
	}

	public SkewHeap(){
		root=null;
		this.Count=0;
	}

	public void Push(T v){
		NodeSH<T> p=new NodeSH<T>(v);
		root=NodeSH<T>.Meld(root,p);
		this.Count++;
	}

	public void Pop(){
		if(root==null)return;
		root=NodeSH<T>.Meld(root.L,root.R);
		this.Count--;
	}

	public T Top{
		get{return root.Val;}
	}

	int cnt;
	NodeSH<T> root;

	class NodeSH<S> where S : IComparable<S> {
		public NodeSH<S> L, R;
		public S Val;

		public NodeSH(S v){
			Val = v;
			L = null; R = null;
		}
		public static NodeSH<S> Meld(NodeSH<S> a, NodeSH<S> b){
			if(a == null)return b;
			if (b == null) return a;
			if (a.Val.CompareTo(b.Val) > 0) swap(ref a, ref b);
			a.R = Meld(a.R, b);
			swap(ref a.L, ref a.R);
			return a;
		}

		static void swap<U>(ref U x, ref U y) {
			U t = x; x = y; y = t;
		}
	}
}


using System;
using System.Collections.Generic;

class Program
{
    private static void Main(string[] args)
    {
        int[] inputData = Console.ReadLine().Split(' ').Select(item => Int32.Parse(item)).ToArray();

        double platesCount = inputData[0];
        double firstCakePieces = inputData[1];
        double secondCakePieces = inputData[2];

        int findedValue;

        if (firstCakePieces + secondCakePieces == platesCount || firstCakePieces == secondCakePieces)
        {
            findedValue = (int)((firstCakePieces + secondCakePieces) / platesCount);
        }
        else
        {
            double piecesOnFirstPlate;
            double piecesOnSecondPlate;
            double lessPart = firstCakePieces > secondCakePieces
                ? Math.Ceiling(platesCount * secondCakePieces / firstCakePieces)
                : Math.Ceiling(platesCount * firstCakePieces / secondCakePieces);

            if (firstCakePieces > secondCakePieces)
            {
                piecesOnFirstPlate = firstCakePieces / (platesCount - lessPart);
                piecesOnSecondPlate = secondCakePieces / lessPart;
            }
            else
            {
                piecesOnFirstPlate = firstCakePieces / lessPart;
                piecesOnSecondPlate = secondCakePieces / (platesCount - lessPart);
            }

            findedValue = (int) (piecesOnFirstPlate < piecesOnSecondPlate ? Math.Ceiling(piecesOnFirstPlate) : Math.Ceiling(piecesOnSecondPlate));
        }

        Console.WriteLine(findedValue);
        Console.ReadLine();
    }
}


#region imports
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

#endregion

namespace CodeForces
{
    class Problem
    {
        const bool IsContest = true;
        long[,] _adj = { { 0, 1, 1, 1 }, { 1, 0, 1, 1 }, { 1, 1, 0, 1 }, { 1, 1, 1, 0 } };

        long[,] Identity()
        {
            var result = new long[Dim, Dim];
            for (var i = 0; i < Dim; i++) result[i, i] = 1;
            return result;
        }

        const long Modulo = 1000000007;
        const int Dim = 4;

        long[,] Product(long[,] a, long[,] b)
        {
            var result = new long[Dim, Dim];
            for (var i = 0; i < Dim; i++)
                for (var j = 0; j < Dim; j++)
                    for (var k = 0; k < Dim; k++) result[i, j] = (result[i, j] + a[i, k] * b[k, j]) % Modulo;
            return result;
        }

        long[,] Power(long[,] a, long n)
        {
            if (n == 0) return Identity();
            if (n == 1) return a;

            var result = Product(Power(a, n / 2), Power(a, n / 2));
            if (n % 2 == 1) result = Product(result, a);
            return result;
        }

        private void Solve()
        {
            var n = _.NextInt();
            var t = Power(_adj, n);
            _.WriteLine(t[0, 0]);
        }

        #region shit
        private readonly InOut _ = new InOut(IsContest);
        static void Main(string[] args)
        {
            var p = new Problem();
            p.Solve();
            p._.Close();
        }
    }
    class InOut
    {
        private const string InputFile = "input.txt";
        private const string OutputFile = "output.txt";
        public StreamWriter Cout { get; private set; }
        public StreamReader Cin { get; private set; }
        private void SetConsoleIo()
        {
            Cin = new StreamReader(new BufferedStream(Console.OpenStandardInput()));
            Cout = new StreamWriter(new BufferedStream(Console.OpenStandardOutput()));
        }
        private void SetFileIo(string inputFile, string outputFile) { Cin = new StreamReader(inputFile); Cout = new StreamWriter(outputFile); }
        public InOut() { SetConsoleIo(); }
        public InOut(string inputFile, string outputFile) { SetFileIo(inputFile, outputFile); }
        public InOut(bool isContest) { if (isContest) SetConsoleIo(); else SetFileIo(InputFile, OutputFile); }
        public void WriteLine(object x) { Cout.WriteLine(x); }
        public void Close() { Cin.Close(); Cout.Close(); }
        public void WriteLine(string format, params object[] args) { Cout.WriteLine(format, args); }
        private int _pos;
        private string[] _tokens;

        private string[] NextStringArray() { return Cin.ReadLine().Split(" \t".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); }
        public string NextToken()
        {
            while (_tokens == null || _pos == _tokens.Length)
            {
                // ReSharper disable once PossibleNullReferenceException
                _tokens = NextStringArray();
                _pos = 0;
            }
            return _tokens[_pos++];
        }
        public int NextInt() { return int.Parse(NextToken()); }
        public long NextLong() { return long.Parse(NextToken()); }
        public double NextDouble() { return double.Parse(NextToken(), CultureInfo.InvariantCulture); }
        public int[] NextIntArray() { return NextStringArray().Select(int.Parse).ToArray(); }
        public byte[] NextByteArray() { return NextStringArray().Select(byte.Parse).ToArray(); }
        public long[] NextLongArray() { return NextStringArray().Select(long.Parse).ToArray(); }
        #endregion
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
namespace Task26A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n, ans = 0;
            n = Convert.ToInt32(Console.ReadLine());
            List <int>  primes=new List <int> ();
            for(int i = 2; i <= n; i++)
                if (isPrime(i))
                    primes.Add(i);

            for (int i = 1; i <= n; i++)
                if (isAlmastPrime(ref primes,i))
                    ans++;

            Console.WriteLine(ans);
        }

         private static bool isPrime(int N)
        {
            if (N == 2) return true;
            if (N < 2 || N % 2 == 0) return false;
            for (int i = 3; i <=Math.Sqrt(N); i += 2)
                if (N % i == 0) return false;
            return true;
        }

          private static bool isAlmastPrime(ref List<int> mylist, int item)
        {
            int count = 0;
            for (int i = 0; i <= mylist.Count; i++) {

                if (i%mylist[i]== 0)
                    count++;
                if (count > 2)
                    return false;
              }
            return count == 2;
        }

    }
}


/*
 * TemplateCS
 * Copyright (C) 2014-2016 Markus Himmel
 * This file is distributed under the terms of the MIT license
 */

//#define CodeJam
#define CodeForces

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;

// ReSharper disable RedundantUsingDirective
using System.IO;

// ReSharper restore RedundantUsingDirective

// ReSharper disable UnusedMember.Local

// ReSharper disable once CheckNamespace

namespace ProgrammingCompetitions
{
    internal class Program
    {
        #region GCJ

#if CodeJam
		private static bool DEBUG = false;

		static void debug()
		{
		}

		static string solveCase(int num)
		{
			checked
			{
				return null;
			}
		}
#endif

        #endregion

        #region CodeForces

#if CodeForces
#if DEBUG
        private static readonly Queue<string> testInput = new Queue<string>(@"

3
BBW

".Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries));
#endif

        private static object solve()
        {
            // ReSharper disable once RedundantOverflowCheckingContext
            checked
            {
                int n = read<int>();
                var e = read().ToCharArray();
                List<int> res = new List<int>();

                int cur = 0;
                foreach (char c in e)
                {
                    if (c == 'W')
                    {
                        if (cur > 0)
                        {
                            res.Add(cur);
                            cur = 0;
                        }
                    }
                    else
                    {
                        cur++;
                    }
                }
                if (res.Count == 0 || cur > 0)
                res.Add(cur);

                Console.WriteLine(res.Count);
                return res;
            }
        }
#endif

        #endregion

        // Everything after this comment is template code

        private static T read<T>()
        {
            return (T)Convert.ChangeType(read(), typeof(T));
        }

        private static T[] readMany<T>()
        {
            // ReSharper disable once PossiblyMistakenUseOfParamsMethod
            return readMany<T>(' ');
        }

        private static T[] readMany<T>(params char[] ___)
        {
            return read().Split(___).Select(__ => (T)Convert.ChangeType(__, typeof(T))).ToArray();
        }

        private static string[] readMany()
        {
            return readMany<string>();
        }

        private static T[][] readMany<T>(int n)
        {
            var res = new T[n][];
            for (int i = 0; i < n; i++)
                res[i] = readMany<T>();
            return res;
        }

        private static T[][] readField<T>(int height, Func<char, T> map)
        {
            var res = new T[height][];
            for (int _ = 0; _ < height; _++)
                res[_] = read().Select(map).ToArray();
            return res;
        }

        private static char[][] readField(int height)
        {
            return readField(height, c => c);
        }

        private static T[][] readField<T>(int height, Dictionary<char, T> dic)
        {
            return readField(height, c => dic[c]);
        }

        private static void read<T1>(out T1 t1)
        {
            string[] vals = readMany();
            t1 = (T1)Convert.ChangeType(vals[0], typeof(T1));
        }

        private static void read<T1, T2>(out T1 t1, out T2 t2)
        {
            string[] vals = readMany();
            t1 = (T1)Convert.ChangeType(vals[0], typeof(T1));
            t2 = (T2)Convert.ChangeType(vals[1], typeof(T2));
        }

        private static void read<T1, T2, T3>(out T1 t1, out T2 t2, out T3 t3)
        {
            string[] vals = readMany();
            t1 = (T1)Convert.ChangeType(vals[0], typeof(T1));
            t2 = (T2)Convert.ChangeType(vals[1], typeof(T2));
            t3 = (T3)Convert.ChangeType(vals[2], typeof(T3));
        }

        private static void read<T1, T2, T3, T4>(out T1 t1, out T2 t2, out T3 t3, out T4 t4)
        {
            string[] vals = readMany();
            t1 = (T1)Convert.ChangeType(vals[0], typeof(T1));
            t2 = (T2)Convert.ChangeType(vals[1], typeof(T2));
            t3 = (T3)Convert.ChangeType(vals[2], typeof(T3));
            t4 = (T4)Convert.ChangeType(vals[3], typeof(T4));
        }

        private static void read<T1, T2, T3, T4, T5>(out T1 t1, out T2 t2, out T3 t3, out T4 t4, out T5 t5)
        {
            string[] vals = readMany();
            t1 = (T1)Convert.ChangeType(vals[0], typeof(T1));
            t2 = (T2)Convert.ChangeType(vals[1], typeof(T2));
            t3 = (T3)Convert.ChangeType(vals[2], typeof(T3));
            t4 = (T4)Convert.ChangeType(vals[3], typeof(T4));
            t5 = (T5)Convert.ChangeType(vals[4], typeof(T5));
        }

        private static Func<T1, TResult> dp<T1, TResult>(Func<T1, Func<T1, TResult>, TResult> f)
        {
            var cache = new Dictionary<Tuple<T1>, TResult>();
            Func<T1, TResult> res = null;
            res = t1 =>
            {
                Tuple<T1> key = Tuple.Create(t1);
                if (!cache.ContainsKey(key))
                    cache.Add(key, f(t1, res));
                return cache[key];
            };
            return res;
        }

        private static Func<T1, T2, TResult> dp<T1, T2, TResult>(Func<T1, T2, Func<T1, T2, TResult>, TResult> f)
        {
            var cache = new Dictionary<Tuple<T1, T2>, TResult>();
            Func<T1, T2, TResult> res = null;
            res = (t1, t2) =>
            {
                Tuple<T1, T2> key = Tuple.Create(t1, t2);
                if (!cache.ContainsKey(key))
                    cache.Add(key, f(t1, t2, res));
                return cache[key];
            };
            return res;
        }

        private static Func<T1, T2, T3, TResult> dp<T1, T2, T3, TResult>(Func<T1, T2, T3, Func<T1, T2, T3, TResult>, TResult> f)
        {
            var cache = new Dictionary<Tuple<T1, T2, T3>, TResult>();
            Func<T1, T2, T3, TResult> res = null;
            res = (t1, t2, t3) =>
            {
                Tuple<T1, T2, T3> key = Tuple.Create(t1, t2, t3);
                if (!cache.ContainsKey(key))
                    cache.Add(key, f(t1, t2, t3, res));
                return cache[key];
            };
            return res;
        }

        private static Func<T1, T2, T3, T4, TResult> dp<T1, T2, T3, T4, TResult>(Func<T1, T2, T3, T4, Func<T1, T2, T3, T4, TResult>, TResult> f)
        {
            var cache = new Dictionary<Tuple<T1, T2, T3, T4>, TResult>();
            Func<T1, T2, T3, T4, TResult> res = null;
            res = (t1, t2, t3, t4) =>
            {
                Tuple<T1, T2, T3, T4> key = Tuple.Create(t1, t2, t3, t4);
                if (!cache.ContainsKey(key))
                    cache.Add(key, f(t1, t2, t3, t4, res));
                return cache[key];
            };
            return res;
        }

        private static IEnumerable<T> single<T>(T it)
        {
            yield return it;
        }

        private static IEnumerable<long> range(long first, long last, long step = 1)
        {
            for (long i = first; i <= last; i += step)
                yield return i;
        }

        private static IEnumerable<int> range(int first, int last, int step = 1)
        {
            for (int i = first; i <= last; i += step)
                yield return i;
        }

        private static T id<T>(T a)
        {
            return a;
        }

        public static T[][] Mkarr<T>(int x, int y)
        {
            var res = new T[x][];
            for (int i = 0; i < x; i++)
                res[i] = new T[y];
            return res;
        }

        public static T[][][] Mkarr<T>(int x, int y, int z)
        {
            var res = new T[x][][];
            for (int i = 0; i < x; i++)
            {
                res[i] = new T[y][];
                for (int j = 0; j < y; j++)
                    res[i][j] = new T[z];
            }
            return res;
        }

        private static long ternarySearch(long from, long to, Func<long, bool> comp)
        {
            from--;
            while (to - from > 1)
            {
                long mid = (from + to) >> 1;
                if (comp(mid))
                    to = mid;
                else
                    from = mid;
            }
            return to;
        }

        public static KeyValuePair<long, long> Min(Func<long, long> f, long from, long to)
        {
            long i = ternarySearch(from, to, mid => f(mid) < f(mid + 1));
            return new KeyValuePair<long, long>(i, f(i));
        }

        public static long Max(params long[] p)
        {
            return p.Max();
        }

        public static int Max(params int[] p)
        {
            return p.Max();
        }

        public static double Max(params double[] p)
        {
            return p.Max();
        }

        public static KeyValuePair<long, long> Max(Func<long, long> f, long from, long to)
        {
            long i = ternarySearch(from, to, mid => f(mid) > f(mid + 1));
            return new KeyValuePair<long, long>(i, f(i));
        }

        public static long Min(params long[] p)
        {
            return p.Min();
        }

        public static int Min(params int[] p)
        {
            return p.Min();
        }

        public static double Min(params double[] p)
        {
            return p.Min();
        }

        private static bool[] tf = { true, false };

#if CodeJam

		static void Main(string[] args)
		{
			if (DEBUG)
			{
				debug();
			}
			else
			{
				Initialize();
				SolveAll(solveCase);
			}
			Console.ReadKey();
		}

		private static StreamReader inf;
		private static StreamWriter outf;

		private delegate void o(string format, params object[] args);
		private static o Output;

		public static void Initialize()
		{
			Console.ForegroundColor = ConsoleColor.Yellow;
			Console.Write("File name: ");
			string name = Console.ReadLine();
			inf = new StreamReader($"D:\\Users\\marku\\Downloads\\{name}.in");
			outf = new StreamWriter($"D:\\Users\\marku\\Downloads\\{name}.out");
			Console.ForegroundColor = ConsoleColor.White;
			Output = highlightedPrint;
			Output += outf.WriteLine;
		}

		private static void highlightedPrint(string format, params object[] args)
		{
			ConsoleColor prev = Console.ForegroundColor;
			Console.ForegroundColor = ConsoleColor.Green;
			Console.WriteLine(format, args);
			Console.ForegroundColor = prev;
		}

		public static void SolveAll(Func<int, string> calc)
		{
			int cases = int.Parse(inf.ReadLine());
			for (int _ = 1; _ <= cases; _++)
			{
				Output($"Case #{_}: {calc(_)}");
			}
			inf.Close();
			outf.Close();
			Console.ForegroundColor = ConsoleColor.Cyan;
			Console.WriteLine("Eureka!");
		}

		private static string read()
		{
			return inf.ReadLine();
		}
#endif

#if CodeForces
        private static string asString(object s)
        {
            if (s is double)
                return ((double)s).ToString("0.000000000", CultureInfo.InvariantCulture);
            return s.ToString();
        }

        public static void Main(string[] args)
        {
#if DEBUG
            Stopwatch sw = new Stopwatch();
            sw.Start();
#endif
            object o = solve();
            if (o != null)
            {
                string s;
                IEnumerable e = o as IEnumerable;
                if ((e != null) && !(o is string))
                    s = string.Join(" ", e.OfType<object>().Select(asString));
                else
                    s = asString(o);
                if (!string.IsNullOrEmpty(s))
                    Console.WriteLine(s);
            }
#if DEBUG
            sw.Stop();
            Console.WriteLine(sw.Elapsed);
            Console.ReadKey();
#endif
        }

        private static string read()
        {
#if !DEBUG
			return Console.ReadLine();
#else
            return testInput.Dequeue();
#endif
        }
#endif
    }

    public static class ExtensionMethods
    {
        public static int BinarySearch<T>(this IList<T> it, Func<T, bool> compare)
        {
            int len = it.Count;
            int first = 0;

            while (len > 0)
            {
                int half = len >> 1;
                T middle = it[first + half];
                if (compare(middle))
                    len = half;
                else
                {
                    first += half + 1;
                    len -= half + 1;
                }
            }

            return first;
        }

        public static int Upper<T>(this IList<T> it, T val)
        {
            Comparer<T> comp = Comparer<T>.Default;
            return it.BinarySearch(other => comp.Compare(val, other) < 0);
        }

        public static int Lower<T>(this IList<T> it, T val)
        {
            Comparer<T> comp = Comparer<T>.Default;
            return it.BinarySearch(other => comp.Compare(other, val) >= 0);
        }

        public static T[] Of<T>(this int n, Func<T> gen)
        {
            return n.Of2(gen).ToArray();
        }

        public static T[] Of<T>(this int n, Func<long, T> gen)
        {
            return n.Of2(gen).ToArray();
        }

        public static T[] Of<T>(this int n, T gen)
        {
            return n.Of2(gen).ToArray();
        }

        public static IEnumerable<T> Of2<T>(this int n, Func<T> gen)
        {
            for (int i = 0; i < n; i++)
                yield return gen();
        }

        public static IEnumerable<T> Of2<T>(this int n, Func<long, T> gen)
        {
            for (int i = 0; i < n; i++)
                yield return gen(i);
        }

        public static IEnumerable<T> Of2<T>(this int n, T gen)
        {
            for (int i = 0; i < n; i++)
                yield return gen;
        }

        public static IEnumerable<TOut> Cartesian<T1, T2, TOut>(this IEnumerable<T1> first, IEnumerable<T2> second, Func<T1, T2, TOut> collector)
        {
            return first.SelectMany(f => second.Select(s => collector(f, s)));
        }

        public static IEnumerable<Tuple<T1, T2>> Cartesian<T1, T2>(this IEnumerable<T1> first, IEnumerable<T2> second)
        {
            return first.Cartesian(second, Tuple.Create);
        }

        public static IEnumerable<Tuple<T1, T2>> CartesianE<T1, T2>(this IEnumerable<T1> first, IEnumerable<T2> second)
        {
            // Calling CartesianE prevents selection of the wrong overload of Cartesian when you want a tuple of tuples to be returned
            return first.Cartesian(second);
        }

        public static IEnumerable<Tuple<T1, T2, T3>> Cartesian<T1, T2, T3>(this IEnumerable<Tuple<T1, T2>> first, IEnumerable<T3> second)
        {
            return first.Cartesian(second, (x, y) => Tuple.Create(x.Item1, x.Item2, y));
        }

        public static IEnumerable<Tuple<T1, T2, T3, T4>> Cartesian<T1, T2, T3, T4>(this IEnumerable<Tuple<T1, T2, T3>> first, IEnumerable<T4> second)
        {
            return first.Cartesian(second, (x, y) => Tuple.Create(x.Item1, x.Item2, x.Item3, y));
        }

        public static IEnumerable<Tuple<T1, T2, T3, T4, T5>> Cartesian<T1, T2, T3, T4, T5>(this IEnumerable<Tuple<T1, T2, T3, T4>> first, IEnumerable<T5> second)
        {
            return first.Cartesian(second, (x, y) => Tuple.Create(x.Item1, x.Item2, x.Item3, x.Item4, y));
        }

        public static IEnumerable<IEnumerable<T>> Cartesian<T>(this IEnumerable<IEnumerable<T>> source)
        {
            IEnumerable<T>[] enumerable = source as IEnumerable<T>[] ?? source.ToArray();
            IEnumerable<IEnumerable<T>> res = enumerable.First().Select(single);
            return enumerable.Skip(1).Aggregate(res, (current, next) => current.Cartesian(next, (sofar, n) => sofar.Concat(single(n))));
        }

        public static IEnumerable<IEnumerable<T>> Pow<T>(this IEnumerable<T> it, int num)
        {
            return Enumerable.Repeat(it, num).Cartesian();
        }

        public static IEnumerable<T> Demask<T>(this IEnumerable<Tuple<T, bool>> inp)
        {
            foreach (Tuple<T, bool> pair in inp)
                if (pair.Item2)
                    yield return pair.Item1;
        }

        public static IEnumerable<IEnumerable<IEnumerable<T>>> Partition<T>(this IEnumerable<T> source, int groups)
        {
            T[] src = source as T[] ?? source.ToArray();
            foreach (int[] part in Enumerable.Range(0, groups).Pow(src.Length).Select(x => x.ToArray()))
                yield return Enumerable.Range(0, groups).Select(x => src.Where((item, idx) => part[idx] == x));
        }

        public static IEnumerable<IEnumerable<T>> Combinations<T>(this IEnumerable<T> it)
        {
            T[] itt = it as T[] ?? it.ToArray();
            foreach (IEnumerable<bool> conf in new[] { true, false }.Pow(itt.Length))
                yield return itt.Zip(conf, Tuple.Create).Demask();
        }

        private static IEnumerable<T> single<T>(T it)
        {
            yield return it;
        }

        private static IEnumerable<T> exceptSingle<T>(this IEnumerable<T> first, T it, IEqualityComparer<T> comp = null)
        {
            comp = comp ?? EqualityComparer<T>.Default;
            bool seen = false;
            foreach (T a in first)
                if (!seen && comp.Equals(a, it))
                    seen = true;
                else
                    yield return a;
        }

        public static IEnumerable<IEnumerable<T>> Permutations<T>(this IEnumerable<T> it)
        {
            T[] src = it as T[] ?? it.ToArray();
            if (src.Length < 2)
            {
                yield return src;
                yield break;
            }

            foreach (T first in src)
                foreach (IEnumerable<T> part in Permutations(src.exceptSingle(first)))
                    yield return single(first).Concat(part);
        }

        public static T[][] Rho<T>(this IEnumerable<T> source, int x, int y)
        {
            T[][] res = Program.Mkarr<T>(x, y);

            int i = 0, j = 0;

            T[] src = source as T[] ?? source.ToArray();
            while (true)
            {
                foreach (T item in src)
                {
                    res[i][j] = item;
                    j++;
                    if (j == y)
                    {
                        j = 0;
                        i++;
                        if (i == x)
                            break;
                    }
                }
                if (i == x)
                    break;
            }

            return res;
        }

        public static T[][][] Rho<T>(this IEnumerable<T> source, int x, int y, int z)
        {
            T[][][] res = Program.Mkarr<T>(x, y, z);

            int i = 0, j = 0, k = 0;
            T[] src = source as T[] ?? source.ToArray();
            while (true)
            {
                foreach (T item in src)
                {
                    res[i][j][k] = item;
                    k++;
                    if (k == z)
                    {
                        k = 0;
                        j++;
                        if (j == y)
                        {
                            j = 0;
                            i++;
                            if (i == x)
                                break;
                        }
                    }
                }
                if (i == x)
                    break;
            }

            return res;
        }
    }
}


using System;
using System.Collections.Generic;

namespace Codeforces
{
    class Program
    {
        static int Sum(int number)
        {
            var rank = 10;
            var last = 0;
            var sum = 0;
            while (number % rank != number)
            {
                var k = number % rank;
                sum += (k - last) / (rank/10);
                last = k;
                rank *= 10;
            }
            sum += (number - last) / (rank/10);
            return sum;
        }

        static void Main()
        {
            var number = int.Parse(Console.ReadLine());
            var dictionary = new Dictionary<int, int>();
            for (var i = 1; i <= number; i++)
            {
                dictionary[i] = Sum(i);
            }

            var maxValue = 0;
            var maxKey = 0;

            foreach (var pair in dictionary)
            {
                if (pair.Value > maxValue)
                {
                    maxValue = pair.Value;
                    maxKey = pair.Key;
                }
                else if (pair.Value == maxValue)
                {
                    if (pair.Key > maxKey)
                        maxKey = pair.Key;
                }
            }

            Console.WriteLine(maxKey);
        }
    }
}


using System;

namespace Codeforces
{
    class Program
    {
        static long Sum(long number)
        {
            var str = number.ToString();
            long sum = 0;
            foreach (var symbol in str)
                sum += symbol - '0';
            return sum;
        }

        static void Main()
        {
            var number = long.Parse(Console.ReadLine());
            long maxSum = 0;
            long answer = 0;
            for (var i = number; i > 0; i--)
            {
                var sum = Sum(i);
                if (sum > maxSum)
                {
                    maxSum = sum;
                    answer = i;
                }
                else if (sum == maxSum)
                {
                    if (i > answer)
                        answer = i;
                }
            }
            Console.WriteLine(answer);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace cvalification_B
{
    class Program
    {
        static void Main(string[] args)
        {

            string xS = Console.ReadLine();
            char[] ar = xS.ToCharArray();
            int i = xS.Length - 1;
            bool flag = false;
            string answer = "";

            if (i == 0)
            {
                answer = ar[i].ToString();
            }
            else
            {

                while (i > 1)
                {
                    if (ar[i] < '9')
                    {
                        ar[i] = '9';
                        flag = true;
                        i--;
                    }
                    else if (flag)
                    {
                        ar[i] = (char)((int)ar[i] - 1);
                        flag = false;
                    }
                }
                if (flag)
                {
                    ar[i] = (char)((int)ar[i] - 1);
                    flag = false;
                }
                if (ar[i] < '8')
                {
                    ar[i] = '9';
                    flag = true;
                    i--;
                }
                if (flag)
                {
                    ar[i] = (char)((int)ar[i] - 1);
                    flag = false;
                }
                for (int r = 0; r < xS.Length; r++)
                {
                    answer += ar[r];
                }
            }

            answer = answer.TrimStart('0');

            Console.WriteLine(answer);
            Console.ReadKey();

        }
    }
}


using System;
using System.Collections.Generic;

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        s = Console.ReadLine().Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

}

class Myon
{
    Scanner cin;
    Random r;
    Myon() { }

    public static void Main()
    {
        new Myon().calc();
    }

    List<int> ret = new List<int>();

    int[,] dp;

    void calc()
    {
        cin = new Scanner();
        int n = cin.nextInt();
        int m = cin.nextInt();
        dp = new int[n + 1, m + 1];
        Console.WriteLine(saiki(n, m));
    }

    int saiki(int a, int b)
    {
        if (a == 0 && b == 0) return a;
        if (dp[a, b] != 0) return dp[a, b];
        int reta = (a / 4) + Math.Min(a % 4, 2);
        int retb = (b / 4) + Math.Min(b % 4, 2);
        int ret = reta * retb;
        ret = Math.Max((a + 2) / 3 * b, ret);
        ret = Math.Max((b + 2) / 3 * a, ret);
        if (a > 3) ret = Math.Max(ret, saiki(a - 3, b) + b);
        if (b > 3) ret = Math.Max(ret, saiki(b - 3, a) + a);
        ret = Math.Max(ret, (a * b + 1) / 2);
        return dp[a, b] = ret;
    }
}


using System;

namespace _1057С
{
    class Program
    {
        static readonly int INF = 1000000000;
        static int n, s, k;
        static int[] r;
        static int[][] dps;

        static bool[] dpsc;
        static string clr;
        static void Main(string[] args)
        {
            (n, s, k) = r3i();
            r = ris();
            s--;
            clr = Console.ReadLine();
            dpsc = new bool[n];
            dps = new int[n][];
            int result = INF;
            for (int i = 0; i < n; i++)
            {
                dp(i);
                result = Math.Min(result, dps[i][k] + Math.Abs(s-i));
            }
            Console.WriteLine(result == INF ? -1 : result);
        }

        static void dp(int cur)
        {
            if (dps[cur] != null)
                return;
            dps[cur] = new int[k+1];
            for (int i = r[cur] + 1; i < k + 1; i++)
            {
                dps[cur][i] = INF;
            }
            for (int to = 0; to < n; to++)
            {
                if (r[to] < r[cur] && clr[to] != clr[cur])
                {
                    dp(to);
                    for (int i = r[cur] + 1; i < k + 1; i++)
                    {
                        dps[cur][i] = Math.Min(dps[cur][i], dps[to][i-r[cur]] + Math.Abs(cur-to));
                    }
                }
            }
        }

        static int[] ris()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), i => Int32.Parse(i));
        }

        static int ri()
        {
            var i = Console.ReadLine();
            return Int32.Parse(i);
        }
        static (int, int) r2i()
        {
            var i = Console.ReadLine().Split(' ');
            return (Int32.Parse(i[0]), Int32.Parse(i[1]));
        }
        static (int, int, int) r3i()
        {
            var i = Console.ReadLine().Split(' ');
            return (Int32.Parse(i[0]), Int32.Parse(i[1]), Int32.Parse(i[2]));
        }
    }
}


using System;
using System.Linq;
using System.Collections.Generic;

class Solution
{
	static void Main (string[] args)
	{
		int[] nums = Console.ReadLine ().Split (' ').Select (int.Parse).ToArray ();
		int n = nums [0];
		int s = nums [1];
		int target = nums [2];
		int[] v = Console.ReadLine ().Split (' ').Select (int.Parse).ToArray ();
		string c = Console.ReadLine ();

		List<Node> nodes = new List<Node> ();
		for (int i = 0; i < n; i++) {
			nodes.Add (new Node (i, v [i], c [i]));
		}
		nodes.ForEach (node => node.AddNeighbors (nodes));

		Node initialNode = new Node (s - 1, 0, ' ');
		initialNode.Neighbors = nodes;

		List<State>[] search = new List<State>[n * n + 2];
		for (int i = 0; i < search.Length; i++) {
			search [i] = new List<State> ();
		}
		search [0].Add (new State{ Missing = target, Current = initialNode });

		for (int t = 0; t < search.Length; t++) {
			foreach (State state in search[t]) {
				if (state.Solved) {
					Console.WriteLine (t - 1);
					return;
				}
				foreach (State s2 in state.Expand()) {
					search [s2.Time].Add (s2);
				}
			}
		}
		Console.WriteLine (-1);
	}

	class State {
		public int Missing;
		public Node Current;
		public int Time;

		public bool Solved => Missing <= 0;

		public IEnumerable<State> Expand() {
			foreach(Node n in Current.Neighbors) {
				State s = new State();
				s.Current = n;
				s.Missing = Missing - n.Value;
				s.Time = Time + Current.Dist(n);
				yield return s;
			}
		}
	}

	class Node {
		public int Index;
		public int Value;
		public char Color;
		public List<Node> Neighbors;

		public Node(int index, int value, char color) {
			this.Index = index;
			this.Value = value;
			this.Color = color;
		}

		public int Dist(Node n) {
			return Math.Abs(Index - n.Index) + (Color == ' ' ? 1 : 0);
		}

		public void AddNeighbors(List<Node> nodes) {
			Neighbors = nodes.Where (n => n.Color != this.Color && n.Value > this.Value).ToList ();
		}
	}
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace codefor
{
    class Program
    {
        static void Main(string[] args)
        {
            string word = Console.ReadLine();
            if (word.Contains("!"))
            {
                int Kr = 0, Kg = 0, Kb = 0, Ky = 0;
                char[] chs = word.ToCharArray();
                for (int i = 0; i + 4 <= word.Count(); i += 4)
                {
                    //0-1-2-3
                    string check = chs[0].ToString() + chs[1].ToString() + chs[2].ToString() + chs[3].ToString() + "";
                    if (check.Contains("!"))
                    {
                        if (chs[i] == '!')
                        {
                            chs[i] = chs[i + 4];
                        }
                        if (chs[i + 1] == '!')
                        {
                            chs[i + 1] = chs[i + 5];
                        }
                        if (chs[i + 2] == '!')
                        {
                            chs[i + 2] = chs[i + 6];
                        }
                        if (chs[i + 3] == '!')
                        {
                            chs[i + 3] = chs[i + 7];
                        }
                    }
                }
                string fix = chs[0].ToString() + chs[1].ToString() + chs[2].ToString() + chs[3].ToString() + "";
                //BRYG-!R!G
                int V = 0;

                foreach(char f in word)
                {
                    if (f.Equals('!'))
                    {
                        if (chs[V].Equals('R'))
                            Kr++;
                        else if (chs[V].Equals('B'))
                            Kb++;
                        else if (chs[V].Equals('Y'))
                            Ky++;
                        else if (chs[V].Equals('G'))
                            Kg++;
                    }
                    if (V == 3)
                    {
                        V = 0;
                    }
                    else
                    {
                        V++;
                    }
                }
                Console.WriteLine(Kr + " " + Kb + " " + Ky + " " + Kg);
            }
            else
            {
                Console.WriteLine("0 0 0 0");
            }

        }
    }
}


using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Numerics;
using System.Text;

namespace contest
{

    class contest
    {

        static void Main(string[] args)
        {

            //var num = Console.ReadLine().Split().Select(int.Parse).ToArray();
            //int n = num[0];
            //int m = num[1];

            //var input = Console.ReadLine().Split().Select(int.Parse).ToArray();

            //int n = int.Parse(Console.ReadLine());

            //var num = Console.ReadLine().Split().Select(int.Parse).ToArray();
            //for (int i = 0; i < n; i++)
            //{
            //    input[i] = Console.ReadLine().Split().Select(int.Parse).ToArray();

            //}

            //int n = int.Parse(Console.ReadLine());
            //var num = Console.ReadLine().Split().Select(int.Parse).ToArray();
            //int n = num[0];
            //int m = num[1];

            //int n = int.Parse(Console.ReadLine());
            //var num = Console.ReadLine().Split().Select(int.Parse).ToArray();

            //var arr = new int[n][];
            //for(int i =0; i< n; i++)
            //{
            //    arr[i] = Console.ReadLine().Split().Select(int.Parse).ToArray();
            //}

            var s = (Console.ReadLine().ToArray());
            int len = s.Length;

            var ans = new int[4];
            var color = new char[] { 'R', 'B', 'Y', 'G' };

            for(int i =0; i< len; i++)
            {
                char cur = s[i];

                if (i - 4 >= 0 && s[i - 4] == '!')
                {
                    s[i - 4] = cur;
                    ans[Array.IndexOf(color, cur)]++;
                }
                if (i + 4 < len && s[i + 4] == '!')
                {
                    s[i + 4] = cur;
                    ans[Array.IndexOf(color, cur)]++;
                }
            }

            while (true)

            {
                var small = new List<int>();
                var three = new List<int>();
            var id = new List<int>();
            for (int i = 0; i < len - 3; i++)
            {
                int cnt = 0;
                for (int j = 0; j < 4; j++)
                {
                    if (s[i + j] == '!') cnt++;
                }

                    if (cnt > 0 && cnt <= 2 && !small.Any(c=>c>=i-3))
                    {
                        small.Add(i);
                    }
                    else if(cnt>0 && cnt==3 && !three.Any(c=>c>=i-3))
                    {
                        three.Add(i);
                    }
                    if ( cnt>0 && !id.Any(c=>c>=i-3))
                {
                    id.Add(i);
                    //i += 3;
                }

            }
                if (id.Count() == 0) break;

                if(small.Count()>0)
                {
                    id = new List<int>(small);
                }
                else if(three.Count()>0)
                {
                    id = new List<int>(three);
                }
            for (int i = 0; i < id.Count(); i++)
            {
                    int ii = id[i];
                for (int j = 0; j < 4; j++)
                {
                    char cur = s[ii + j];
                    if (cur == '!')
                    {
                        for (int k = 0; k < 4; k++)
                        {
                            if (check(ii + j, len, s, color[k]))
                            {
                                s[ii + j] = color[k];
                                ans[k]++;
                                break;
                            }
                        }
                    }
                }
            }
        }

            //    for (int i=0; i<id.Count(); i++)
            //{

            //        var cnt = new int[4];
            //        var list = new List<int>();
            //        for (int j = 0; j < 4; j++)
            //        {
            //            char cur = s[i+j];
            //            if (cur == 'R')
            //            {
            //                cnt[0]++;
            //            }
            //            else if (cur == 'B')
            //            {
            //                cnt[1]++;
            //            }
            //            else if (cur == 'Y')
            //            {
            //                cnt[2]++;
            //            }
            //            else if (cur == 'G')
            //            {
            //                cnt[3]++;
            //            }
            //            else
            //            {
            //                list.Add(i + j);
            //            }
            //        }
            //        if (list.Count() == 0) continue;
            //        for (int j = 0; j < 4; j++)
            //        {
            //            if (cnt[j] == 0)
            //            {
            //                ans[j]++;
            //                s[list.First()] = color[j];
            //                list.RemoveAt(0);
            //            }
            //        }

            //}

            //for(int i=0; i< len-3; i++)
            //{
            //    var tmp = s.Skip(i).Take(4).ToArray();
            //    var cnt = new int[4];
            //    var list = new List<int>();
            //    for (int j = 0; j < 4; j++)
            //    {
            //        char cur = tmp[j];
            //        if (cur == 'R')
            //        {
            //            cnt[0]++;
            //        }
            //        else if (cur == 'B')
            //        {
            //            cnt[1]++;
            //        }
            //        else if (cur == 'Y')
            //        {
            //            cnt[2]++;
            //        }
            //        else if (cur == 'G')
            //        {
            //            cnt[3]++;
            //        }
            //        else
            //        {
            //            list.Add(i+j);
            //        }
            //    }
            //    if (list.Count()==0) continue;
            //    for(int j=0; j<4;j++)
            //    {
            //        if (cnt[j] == 0)
            //        {
            //            ans[j]++;
            //            s[list.First()] = color[j];
            //            list.RemoveAt(0);
            //        }
            //    }
            //}

            Console.WriteLine(string.Join(" ",ans));

            //Console.WriteLine();

            }

      public static bool check(int i, int n, char[] s,    char target)
        {
            //bool ok = false;

            //if(ok)
            //{
            //    cp.CopyTo(s,0);
            //    return s;
            //}

            for(int j = 1; j<4; j++)
            {
                if (i - j < 0) break;
                char cc = s[j];
                if (s[i - j] == target) return false;

            }

            for (int j = 1; j < 4; j++)
            {
                if (i + j >= n) break;
                char cc = s[j];
                if (s[i + j] == target) return false;

            }
            return true;

        }

    }

        class Segment
        {
        public int[] arr;

            public int n;

            public Segment(int m)
            {
                this.n = m ;
            //arr = Enumerable.Range(0, n*2).ToArray();
            arr = new int[n*4];

            for (int i = 0; i < n*4; i++)
            {
                arr[i] = int.MaxValue;
            }

        }

        //public void update(int p, int value)
        //{  // set value at position p
        //    for (arr[p += n] = value; p > 1; p >>= 1) arr[p >> 1] = Math.Min( arr[p] , arr[p ^ 1]);
        //}

        //public void update(int i, int value)
        //{
        //    i += n / 2;
        //    arr[i] = value;
        //    for (; i > 1; i >>= 1)
        //        arr[i >> 1] = Math.Min(arr[i], arr[i ^ 1]);
        //}

        public void update(int i, int x)
        {
            //i = (n / 2) + i - 1;
            i = n + i - 1;
            arr[i] = x;

            while (i > 0)
            {
                i = (i - 1) / 2;
                arr[i] = Math.Min(arr[(i * 2) + 1], arr[(i * 2) + 2]);

                //if (arr[i * 2 + 1] > arr[i * 2 + 2])
                //{
                //    arr[i] = arr[i * 2 + 1];
                //}
                //else
                //{
                //    arr[i] = arr[i * 2 + 2];
                //}
                //arr[i] = arr[i * 2 + 1] + arr[i * 2 + 2];

            }

        }

        //call : query(a,b, 0, 0, n)
        public int query(int a, int b, int k, int l, int r)
        {
            if (r <= a || b <= l) return int.MaxValue;
            if (a <= l && r <= b) return arr[k];

            //return Math.Min(query(a, b, (k * 2) + 1, l, (l + r) / 2), query(a, b, (k * 2) + 2, (l + r) / 2, r));

            var vl = query(a, b, (k * 2) + 1, l, (l + r) / 2);
            var vr = query(a, b, (k * 2) + 2, (l + r) / 2, r);

            //var vl = query(a, b, (k << 1) + 1, l, (l + r) / 2);
            //var vr = query(a, b, (k + 1) << 1, (l + r) / 2, r);

            if (vl == int.MaxValue && vr == int.MaxValue) return 0;
            return Math.Min(vl, vr);

        }

        //public int query(int a, int b, int k, int l, int r)
        //{
        //    // query for arr[i..j]

        //    if (l > b || r < a)               // segment completely outside range
        //        return int.MaxValue;                       // represents a null node

        //    if (a <= l && b >= r)             // segment completely inside range
        //        return arr[k];

        //    int mid = l + (r - l) / 2;       // partial overlap of current segment and queried range. Recurse deeper.

        //    if (a > mid)
        //        return query(2 * k + 2, mid + 1, r, a, b);
        //    else if (b <= mid)
        //        return query(2 * k + 1, l, mid, a, b);

        //    int leftQuery = query(2 * k + 1, l, mid, a, mid);
        //    int rightQuery = query(2 * k + 2, mid + 1, r, mid + 1, b);

        //    // merge query results
        //    if (leftQuery == int.MaxValue && rightQuery == int.MaxValue) return 0;
        //    return Math.Min(leftQuery, rightQuery);

        //}

        //public int query(int l, int r)
        //{
        //    int res = int.MaxValue;
        //    for (l += n, r += n; l < r; l >>= 1, r >>= 1)
        //    {
        //        if ((l & 1) == 1) res = Math.Min(res, arr[l++]);
        //        if ((r & 1) == 1) res = Math.Min(res, arr[--r]);
        //    }
        //    return res;
        //}

        //public int query(int a, int b, int r)
        //{
        //    int res = int.MaxValue;
        //    for (a += r / 2, b += r / 2; a <= b; a = (a + 1) >> 1, b = (b - 1) >> 1)
        //    //for (; a <= b; a = (a + 1) >> 1, b = (b - 1) >> 1)
        //    {
        //        if ((a & 1) != 0)
        //            res = Math.Min(res, arr[a]);
        //        if ((b & 1) == 0)
        //            res = Math.Min(res, arr[b]);
        //    }
        //    return res;
        //}

        //public int query(int l, int r)
        //{  // sum on interval [l, r)
        //    int res = int.MaxValue;
        //    for (l += n, r += n; l < r; l >>= 1, r >>= 1)
        //    {
        //        if ((l & 1) == 1) res = Math.Min(res, arr[l++]);

        //        if ((r & 1) == 1) res = Math.Min(res, arr[--r]);
        //    }
        //    return res;
        //}

    }

    class UnionFind
        {
            public int[] path;

            public UnionFind(int n)
            {
                path = new int[n];

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

            }

            private int root(int i)
            {
                while (i != path[i])
                {
                    path[i] = path[path[i]];
                    i = path[i];
                }
                return i;
            }

            public bool find(int p, int q)
            {
                return root(p) == root(q);
            }

            public void unite(int p, int q)
            {
                int i = root(p);
                int j = root(q);
                path[i] = j;
            }

        }
    }


using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Numerics;
using System.Text;

namespace contest
{

    class contest
    {

        static void Main(string[] args)
        {

            //var num = Console.ReadLine().Split().Select(int.Parse).ToArray();
            //int n = num[0];
            //int m = num[1];

            //var input = Console.ReadLine().Split().Select(int.Parse).ToArray();

            //int n = int.Parse(Console.ReadLine());

            //var num = Console.ReadLine().Split().Select(int.Parse).ToArray();
            //for (int i = 0; i < n; i++)
            //{
            //    input[i] = Console.ReadLine().Split().Select(int.Parse).ToArray();

            //}

            //int n = int.Parse(Console.ReadLine());
            //var num = Console.ReadLine().Split().Select(int.Parse).ToArray();
            //int n = num[0];
            //int m = num[1];

            //int n = int.Parse(Console.ReadLine());
            //var num = Console.ReadLine().Split().Select(int.Parse).ToArray();

            //var arr = new int[n][];
            //for(int i =0; i< n; i++)
            //{
            //    arr[i] = Console.ReadLine().Split().Select(int.Parse).ToArray();
            //}

            var s = (Console.ReadLine().ToArray());
            int len = s.Length;

            var ans = new int[4];
            var color = new char[] { 'R', 'B', 'Y', 'G' };

            for(int i =0; i< len; i++)
            {
                char cur = s[i];
                if (cur == '!') continue;

                if (i - 4 >= 0 && s[i - 4] == '!')
                {
                    s[i - 4] = cur;
                    ans[Array.IndexOf(color, cur)]++;
                }
                if (i + 4 < len && s[i + 4] == '!')
                {
                    s[i + 4] = cur;
                    ans[Array.IndexOf(color, cur)]++;
                }
            }

            while (true)

            {
                var small = new List<int>();
                var three = new List<int>();
            var id = new List<int>();
            for (int i = 0; i < len - 3; i++)
            {
                int cnt = 0;
                for (int j = 0; j < 4; j++)
                {
                    if (s[i + j] == '!') cnt++;
                }

                    if (cnt > 0 && cnt <= 2 && !small.Any(c=>c>=i-3))
                    {
                        small.Add(i);
                    }
                    else if(cnt>0 && cnt==3 && !three.Any(c=>c>=i-3))
                    {
                        three.Add(i);
                    }
                    if ( cnt>0 && !id.Any(c=>c>=i-3))
                {
                    id.Add(i);
                    //i += 3;
                }

            }
                if (id.Count() == 0) break;

                if(small.Count()>0)
                {
                    id = new List<int>(small);
                }
                else if(three.Count()>0)
                {
                    id = new List<int>(three);
                }
            for (int i = 0; i < id.Count(); i++)
            {
                    int ii = id[i];
                for (int j = 0; j < 4; j++)
                {
                    char cur = s[ii + j];
                    if (cur == '!')
                    {
                        for (int k = 0; k < 4; k++)
                        {
                            if (check(ii + j, len, s, color[k]))
                            {
                                s[ii + j] = color[k];
                                ans[k]++;
                                break;
                            }
                        }
                    }
                }
            }
        }

            //    for (int i=0; i<id.Count(); i++)
            //{

            //        var cnt = new int[4];
            //        var list = new List<int>();
            //        for (int j = 0; j < 4; j++)
            //        {
            //            char cur = s[i+j];
            //            if (cur == 'R')
            //            {
            //                cnt[0]++;
            //            }
            //            else if (cur == 'B')
            //            {
            //                cnt[1]++;
            //            }
            //            else if (cur == 'Y')
            //            {
            //                cnt[2]++;
            //            }
            //            else if (cur == 'G')
            //            {
            //                cnt[3]++;
            //            }
            //            else
            //            {
            //                list.Add(i + j);
            //            }
            //        }
            //        if (list.Count() == 0) continue;
            //        for (int j = 0; j < 4; j++)
            //        {
            //            if (cnt[j] == 0)
            //            {
            //                ans[j]++;
            //                s[list.First()] = color[j];
            //                list.RemoveAt(0);
            //            }
            //        }

            //}

            //for(int i=0; i< len-3; i++)
            //{
            //    var tmp = s.Skip(i).Take(4).ToArray();
            //    var cnt = new int[4];
            //    var list = new List<int>();
            //    for (int j = 0; j < 4; j++)
            //    {
            //        char cur = tmp[j];
            //        if (cur == 'R')
            //        {
            //            cnt[0]++;
            //        }
            //        else if (cur == 'B')
            //        {
            //            cnt[1]++;
            //        }
            //        else if (cur == 'Y')
            //        {
            //            cnt[2]++;
            //        }
            //        else if (cur == 'G')
            //        {
            //            cnt[3]++;
            //        }
            //        else
            //        {
            //            list.Add(i+j);
            //        }
            //    }
            //    if (list.Count()==0) continue;
            //    for(int j=0; j<4;j++)
            //    {
            //        if (cnt[j] == 0)
            //        {
            //            ans[j]++;
            //            s[list.First()] = color[j];
            //            list.RemoveAt(0);
            //        }
            //    }
            //}

            Console.WriteLine(string.Join(" ",ans));

            //Console.WriteLine();

            }

      public static bool check(int i, int n, char[] s,    char target)
        {
            //bool ok = false;

            //if(ok)
            //{
            //    cp.CopyTo(s,0);
            //    return s;
            //}

            for(int j = 1; j<4; j++)
            {
                if (i - j < 0) break;
                char cc = s[j];
                if (s[i - j] == target) return false;

            }

            for (int j = 1; j < 4; j++)
            {
                if (i + j >= n) break;
                char cc = s[j];
                if (s[i + j] == target) return false;

            }
            return true;

        }

    }

        class Segment
        {
        public int[] arr;

            public int n;

            public Segment(int m)
            {
                this.n = m ;
            //arr = Enumerable.Range(0, n*2).ToArray();
            arr = new int[n*4];

            for (int i = 0; i < n*4; i++)
            {
                arr[i] = int.MaxValue;
            }

        }

        //public void update(int p, int value)
        //{  // set value at position p
        //    for (arr[p += n] = value; p > 1; p >>= 1) arr[p >> 1] = Math.Min( arr[p] , arr[p ^ 1]);
        //}

        //public void update(int i, int value)
        //{
        //    i += n / 2;
        //    arr[i] = value;
        //    for (; i > 1; i >>= 1)
        //        arr[i >> 1] = Math.Min(arr[i], arr[i ^ 1]);
        //}

        public void update(int i, int x)
        {
            //i = (n / 2) + i - 1;
            i = n + i - 1;
            arr[i] = x;

            while (i > 0)
            {
                i = (i - 1) / 2;
                arr[i] = Math.Min(arr[(i * 2) + 1], arr[(i * 2) + 2]);

                //if (arr[i * 2 + 1] > arr[i * 2 + 2])
                //{
                //    arr[i] = arr[i * 2 + 1];
                //}
                //else
                //{
                //    arr[i] = arr[i * 2 + 2];
                //}
                //arr[i] = arr[i * 2 + 1] + arr[i * 2 + 2];

            }

        }

        //call : query(a,b, 0, 0, n)
        public int query(int a, int b, int k, int l, int r)
        {
            if (r <= a || b <= l) return int.MaxValue;
            if (a <= l && r <= b) return arr[k];

            //return Math.Min(query(a, b, (k * 2) + 1, l, (l + r) / 2), query(a, b, (k * 2) + 2, (l + r) / 2, r));

            var vl = query(a, b, (k * 2) + 1, l, (l + r) / 2);
            var vr = query(a, b, (k * 2) + 2, (l + r) / 2, r);

            //var vl = query(a, b, (k << 1) + 1, l, (l + r) / 2);
            //var vr = query(a, b, (k + 1) << 1, (l + r) / 2, r);

            if (vl == int.MaxValue && vr == int.MaxValue) return 0;
            return Math.Min(vl, vr);

        }

        //public int query(int a, int b, int k, int l, int r)
        //{
        //    // query for arr[i..j]

        //    if (l > b || r < a)               // segment completely outside range
        //        return int.MaxValue;                       // represents a null node

        //    if (a <= l && b >= r)             // segment completely inside range
        //        return arr[k];

        //    int mid = l + (r - l) / 2;       // partial overlap of current segment and queried range. Recurse deeper.

        //    if (a > mid)
        //        return query(2 * k + 2, mid + 1, r, a, b);
        //    else if (b <= mid)
        //        return query(2 * k + 1, l, mid, a, b);

        //    int leftQuery = query(2 * k + 1, l, mid, a, mid);
        //    int rightQuery = query(2 * k + 2, mid + 1, r, mid + 1, b);

        //    // merge query results
        //    if (leftQuery == int.MaxValue && rightQuery == int.MaxValue) return 0;
        //    return Math.Min(leftQuery, rightQuery);

        //}

        //public int query(int l, int r)
        //{
        //    int res = int.MaxValue;
        //    for (l += n, r += n; l < r; l >>= 1, r >>= 1)
        //    {
        //        if ((l & 1) == 1) res = Math.Min(res, arr[l++]);
        //        if ((r & 1) == 1) res = Math.Min(res, arr[--r]);
        //    }
        //    return res;
        //}

        //public int query(int a, int b, int r)
        //{
        //    int res = int.MaxValue;
        //    for (a += r / 2, b += r / 2; a <= b; a = (a + 1) >> 1, b = (b - 1) >> 1)
        //    //for (; a <= b; a = (a + 1) >> 1, b = (b - 1) >> 1)
        //    {
        //        if ((a & 1) != 0)
        //            res = Math.Min(res, arr[a]);
        //        if ((b & 1) == 0)
        //            res = Math.Min(res, arr[b]);
        //    }
        //    return res;
        //}

        //public int query(int l, int r)
        //{  // sum on interval [l, r)
        //    int res = int.MaxValue;
        //    for (l += n, r += n; l < r; l >>= 1, r >>= 1)
        //    {
        //        if ((l & 1) == 1) res = Math.Min(res, arr[l++]);

        //        if ((r & 1) == 1) res = Math.Min(res, arr[--r]);
        //    }
        //    return res;
        //}

    }

    class UnionFind
        {
            public int[] path;

            public UnionFind(int n)
            {
                path = new int[n];

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

            }

            private int root(int i)
            {
                while (i != path[i])
                {
                    path[i] = path[path[i]];
                    i = path[i];
                }
                return i;
            }

            public bool find(int p, int q)
            {
                return root(p) == root(q);
            }

            public void unite(int p, int q)
            {
                int i = root(p);
                int j = root(q);
                path[i] = j;
            }

        }
    }


using System;
using CompLib.Util;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        int k = sc.NextInt();

        // 最初飴を1つ入れる

        // 飴を1つ食べる
        // 前回入れる操作した個数+1入れる

        // n回操作してk個飴入ってる 食べた個数

        // 食べた x回

        for (long x = 0; x <= n; x++)
        {
            long y = n - x;
            long t = (y + 1) * y / 2 - x;
            if (t == k)
            {
                Console.WriteLine(x);
                return;
            }
        }
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s;
                do
                {
                    s = Console.ReadLine();
                } while (s.Length == 0);

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public string ReadLine()
        {
            _index = _line.Length;
            return Console.ReadLine();
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Konfeti
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split();
            var n = int.Parse(s[0]);
            var k = int.Parse(s[1]);

            var i = 1;
            var ans = -1;
            while (ans==-1)
            {
                var eat = n - i;
                if (i * (i + 1) / 2 - eat == k)
                {
                    ans = eat;
                }

                i++;
            }

            Console.Write(ans);

        }
    }
}


using System;

public class BlackWhiteMagic {

    public static void Main()
    {
        string[] ss = Console.ReadLine().Split();

        int n = int.Parse(ss[0]);
        int m = int.Parse(ss[1]);
        int k = int.Parse(ss[2]);

        long res = 1;

        if (k>n)
        {
            for (int i = 0; i < n; i++) res = (res * m) % 1000000007;
        }
        else if (k == n)
        {
            for (int i = 0; i < (n + 1) / 2; i++) res = (res * m) % 1000000007;
        }
        else
        {
            if (k%2 == 0) res = m;
            else res = m*m;
        }

        Console.WriteLine(res);
    }
}


using System;

namespace Olymp630R
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
if (n == 1) Console.Write(1);
else if (n %2 == 0) Console.Write(2);
else Console.Write(1);
            Console.ReadLine();
        }
    }
}


using System;

namespace ConsoleApplication1
{
    static class Program
    {
        private static void Main()
        {
            var n = int.Parse(Console.ReadLine());

            int answer;
            if (n % 2 == 0)
            {
                answer = 2;
            }
            else
            {
                answer = 1;
            }

            Console.WriteLine(answer);
        }
    }
}


using System;
using System.Linq;
using System.Collections.Generic;
using Debug = System.Diagnostics.Debug;
using StringBuilder = System.Text.StringBuilder;
using System.Numerics;
using Point = System.Numerics.Complex;
using Number = System.Int64;
namespace Program
{
    public class Solver
    {
        public void Solve()
        {
            var q = sc.Integer();
            var par = new int[500000];
            par[0] = -1;
            var dp = Enumerate(500000, x => new double[35]);
            for (int i = 1; i < 35; i++)
                dp[0][i] = 1.0;

            var ptr = 1;
            Action<int> recalc = null;
            recalc = v =>
              {
                  for (int h = 1; h < 35; h++)
                      dp[v][h] = 1.0;
                  var ps = new List<int>();
                  for (int h = 0; h <= 35; h++)
                  {
                      if (v == -1) break;
                      ps.Add(v);
                      v = par[v];
                  }
                  for (int i = ps.Count - 2; i > 0; i--)
                  {
                      var u = ps[i]; var h = i;
                      var p = ps[i + 1];
                      dp[p][h + 1] /= (dp[u][h] + 1) / 2;
                  }
                  for (int i = 0; i + 1 < ps.Count; i++)
                  {
                      var u = ps[i]; var h = i;
                      var p = ps[i + 1];
                      dp[p][h + 1] *= (dp[u][h] + 1) / 2;
                  }
              };
            for (int i = 0; i < q; i++)
            {
                if (sc.Integer() == 1)
                {
                    var p = sc.Integer() - 1;
                    par[ptr] = p;
                    recalc(ptr);
                    ptr++;

                }
                else
                {
                    var v = sc.Integer() - 1;
                    var ans = 0.0;
                    for (int h = 1; h < 35; h++)
                        ans += dp[v][h] - dp[v][h - 1];
                    Debug.WriteLine(dp[v].AsJoinedString());
                    IO.Printer.Out.WriteLine(ans);

                }
            }
        }
        public IO.StreamScanner sc = new IO.StreamScanner(Console.OpenStandardInput());
        static T[] Enumerate<T>(int n, Func<int, T> f) { var a = new T[n]; for (int i = 0; i < n; ++i) a[i] = f(i); return a; }
        static public void Swap<T>(ref T a, ref T b) { var tmp = a; a = b; b = tmp; }
    }
}

#region main
static class Ex
{
    static public string AsString(this IEnumerable<char> ie) { return new string(System.Linq.Enumerable.ToArray(ie)); }
    static public string AsJoinedString<T>(this IEnumerable<T> ie, string st = " ") { return string.Join(st, ie); }
    static public void Main()
    {
        var solver = new Program.Solver();
        solver.Solve();
        Program.IO.Printer.Out.Flush();
    }
}
#endregion
#region Ex
namespace Program.IO
{
    using System.IO;
    using System.Text;
    using System.Globalization;
    public class Printer: StreamWriter
    {
        static Printer() { Out = new Printer(Console.OpenStandardOutput()) { AutoFlush = false }; }
        public static Printer Out { get; set; }
        public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
        public Printer(System.IO.Stream stream) : base(stream, new UTF8Encoding(false, true)) { }
        public Printer(System.IO.Stream stream, Encoding encoding) : base(stream, encoding) { }
        public void Write<T>(string format, T[] source) { base.Write(format, source.OfType<object>().ToArray()); }
        public void WriteLine<T>(string format, T[] source) { base.WriteLine(format, source.OfType<object>().ToArray()); }
    }
    public class StreamScanner
    {
        public StreamScanner(Stream stream) { str = stream; }
        public readonly Stream str;
        private readonly byte[] buf = new byte[1024];
        private int len, ptr;
        public bool isEof = false;
        public bool IsEndOfStream { get { return isEof; } }
        private byte read()
        {
            if (isEof) return 0;
            if (ptr >= len) { ptr = 0; if ((len = str.Read(buf, 0, 1024)) <= 0) { isEof = true; return 0; } }
            return buf[ptr++];
        }
        public char Char() { byte b = 0; do b = read(); while ((b < 33 || 126 < b) && !isEof); return (char)b; }

        public string Scan()
        {
            var sb = new StringBuilder();
            for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
                sb.Append(b);
            return sb.ToString();
        }
        public string ScanLine()
        {
            var sb = new StringBuilder();
            for (var b = Char(); b != '\n'; b = (char)read())
                if (b == 0) break;
                else if (b != '\r') sb.Append(b);
            return sb.ToString();
        }
        public long Long()
        {
            if (isEof) return long.MinValue;
            long ret = 0; byte b = 0; var ng = false;
            do b = read();
            while (b != 0 && b != '-' && (b < '0' || '9' < b));
            if (b == 0) return long.MinValue;
            if (b == '-') { ng = true; b = read(); }
            for (; true; b = read())
            {
                if (b < '0' || '9' < b)
                    return ng ? -ret : ret;
                else ret = ret * 10 + b - '0';
            }
        }
        public int Integer() { return (isEof) ? int.MinValue : (int)Long(); }
        public double Double() { var s = Scan(); return s != "" ? double.Parse(s, CultureInfo.InvariantCulture) : double.NaN; }
        private T[] enumerate<T>(int n, Func<T> f)
        {
            var a = new T[n];
            for (int i = 0; i < n; ++i) a[i] = f();
            return a;
        }

        public char[] Char(int n) { return enumerate(n, Char); }
        public string[] Scan(int n) { return enumerate(n, Scan); }
        public double[] Double(int n) { return enumerate(n, Double); }
        public int[] Integer(int n) { return enumerate(n, Integer); }
        public long[] Long(int n) { return enumerate(n, Long); }
    }
}
#endregion


using System;
using System.Linq;
using System.Collections.Generic;
using Debug = System.Diagnostics.Debug;
using StringBuilder = System.Text.StringBuilder;
using System.Numerics;
using Point = System.Numerics.Complex;
using Number = System.Int64;
namespace Program
{
    public class Solver
    {
        public void Solve()
        {
            var q = sc.Integer();
            var par = new int[500002];
            par[0] = -1;
            var dp = Enumerate(500002, x => new double[35]);
            for (int i = 1; i < 35; i++)
                dp[0][i] = 1.0;

            var ptr = 1;
            Action<int> recalc = null;
            recalc = v =>
              {
                  for (int h = 1; h < 35; h++)
                      dp[v][h] = 1.0;
                  var ps = new List<int>();
                  for (int h = 0; h <= 35; h++)
                  {
                      if (v == -1) break;
                      ps.Add(v);
                      v = par[v];
                  }
                  for (int i = ps.Count - 2; i > 0; i--)
                  {
                      var u = ps[i]; var h = i;
                      var p = ps[i + 1];
                      dp[p][h + 1] /= (dp[u][h] + 1) / 2;
                  }
                  for (int i = 0; i + 1 < ps.Count; i++)
                  {
                      var u = ps[i]; var h = i;
                      var p = ps[i + 1];
                      dp[p][h + 1] *= (dp[u][h] + 1) / 2;
                  }
              };
            for (int i = 0; i < q; i++)
            {
                if (sc.Integer() == 1)
                {
                    var p = sc.Integer() - 1;
                    par[ptr] = p;
                    recalc(ptr);
                    ptr++;

                }
                else
                {
                    var v = sc.Integer() - 1;
                    var ans = 0.0;
                    for (int h = 1; h < 35; h++)
                        ans += 1 - dp[v][h];
                    Debug.WriteLine(dp[v].AsJoinedString());
                    IO.Printer.Out.WriteLine(ans);

                }
            }
        }
        public IO.StreamScanner sc = new IO.StreamScanner(Console.OpenStandardInput());
        static T[] Enumerate<T>(int n, Func<int, T> f) { var a = new T[n]; for (int i = 0; i < n; ++i) a[i] = f(i); return a; }
        static public void Swap<T>(ref T a, ref T b) { var tmp = a; a = b; b = tmp; }
    }
}

#region main
static class Ex
{
    static public string AsString(this IEnumerable<char> ie) { return new string(System.Linq.Enumerable.ToArray(ie)); }
    static public string AsJoinedString<T>(this IEnumerable<T> ie, string st = " ") { return string.Join(st, ie); }
    static public void Main()
    {
        var solver = new Program.Solver();
        solver.Solve();
        Program.IO.Printer.Out.Flush();
    }
}
#endregion
#region Ex
namespace Program.IO
{
    using System.IO;
    using System.Text;
    using System.Globalization;
    public class Printer: StreamWriter
    {
        static Printer() { Out = new Printer(Console.OpenStandardOutput()) { AutoFlush = false }; }
        public static Printer Out { get; set; }
        public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
        public Printer(System.IO.Stream stream) : base(stream, new UTF8Encoding(false, true)) { }
        public Printer(System.IO.Stream stream, Encoding encoding) : base(stream, encoding) { }
        public void Write<T>(string format, T[] source) { base.Write(format, source.OfType<object>().ToArray()); }
        public void WriteLine<T>(string format, T[] source) { base.WriteLine(format, source.OfType<object>().ToArray()); }
    }
    public class StreamScanner
    {
        public StreamScanner(Stream stream) { str = stream; }
        public readonly Stream str;
        private readonly byte[] buf = new byte[1024];
        private int len, ptr;
        public bool isEof = false;
        public bool IsEndOfStream { get { return isEof; } }
        private byte read()
        {
            if (isEof) return 0;
            if (ptr >= len) { ptr = 0; if ((len = str.Read(buf, 0, 1024)) <= 0) { isEof = true; return 0; } }
            return buf[ptr++];
        }
        public char Char() { byte b = 0; do b = read(); while ((b < 33 || 126 < b) && !isEof); return (char)b; }

        public string Scan()
        {
            var sb = new StringBuilder();
            for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
                sb.Append(b);
            return sb.ToString();
        }
        public string ScanLine()
        {
            var sb = new StringBuilder();
            for (var b = Char(); b != '\n'; b = (char)read())
                if (b == 0) break;
                else if (b != '\r') sb.Append(b);
            return sb.ToString();
        }
        public long Long()
        {
            if (isEof) return long.MinValue;
            long ret = 0; byte b = 0; var ng = false;
            do b = read();
            while (b != 0 && b != '-' && (b < '0' || '9' < b));
            if (b == 0) return long.MinValue;
            if (b == '-') { ng = true; b = read(); }
            for (; true; b = read())
            {
                if (b < '0' || '9' < b)
                    return ng ? -ret : ret;
                else ret = ret * 10 + b - '0';
            }
        }
        public int Integer() { return (isEof) ? int.MinValue : (int)Long(); }
        public double Double() { var s = Scan(); return s != "" ? double.Parse(s, CultureInfo.InvariantCulture) : double.NaN; }
        private T[] enumerate<T>(int n, Func<T> f)
        {
            var a = new T[n];
            for (int i = 0; i < n; ++i) a[i] = f();
            return a;
        }

        public char[] Char(int n) { return enumerate(n, Char); }
        public string[] Scan(int n) { return enumerate(n, Scan); }
        public double[] Double(int n) { return enumerate(n, Double); }
        public int[] Integer(int n) { return enumerate(n, Integer); }
        public long[] Long(int n) { return enumerate(n, Long); }
    }
}
#endregion


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Code
{
    class Program
    {
        static void Main(string[] args)
        {

            int zeros = 0;
            int digits = 0;

            var line = Console.ReadLine();
            var tokens = line.Split(' ');

            int N = Convert.ToInt32(tokens[0]);
            int K = Convert.ToInt32(tokens[1]);

            int n = N;

            while ( n>0 )
            {
                if (n % 10 == 0)
                    zeros++;
                n /= 10;

                digits++;
            }

            if ( K>zeros)
                Console.WriteLine(digits - 1);
            else
            {
                int counter = 0;
                int remove = 0;
                while ( N>0)
                {

                    if ( counter == K)
                    {
                        Console.WriteLine(remove);
                        return;
                    }

                    if (N % 10 == 0)
                        counter++;
                    else
                        remove++;

                    N /= 10;
                }
            }

        }
    }
}