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

namespace ExInCsharp
{
    class Program
    {
        static void Main(string[] args)
        {
            string str1 = Console.ReadLine();
            int x=0, y=0, m, n;
            bool f = false;
            string[] str = str1.Split(' ');
            n = int.Parse(str[0]); m = int.Parse(str[1]);
            for (int i = 1; i <= n; i++ )
            {
                for (int j=1; j<=m; j++)
                {
                    if ((i+j)%5==0)
                    {
                        x++;
                    }
                }

            }

            Console.WriteLine(x);

        }
    }
}


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

namespace ConsoleApp11
{
    class Program
    {
        static void Main(string[] args)
        {
            ulong[] inp = Console.ReadLine().Split().Select(ulong.Parse).ToArray();
            ulong l1 = inp[0];
            ulong r1 = inp[1];
            ulong l2 = inp[2];
            ulong r2 = inp[3];
            ulong k = inp[4];
            ulong y = 0;
            if (l2 > r1 || l1 > r2)
            {
                Console.WriteLine(0);
            }
            else
            {
                for (ulong i = l2; i <= r2; i++)
                {
                    if (i >= l1 && i <= r1)
                    {
                         if ((i < k && r1 - i+1 > y && (k > r1))|| (i > k && r1 - i > y && (k < r1)))
                        {
                            y = r1 - i+1;
                            continue;
                        }
                       else if(r1-i>y)
                        {
                            y = r1 - i ;
                            continue;
                        }

                    }
                    if (i > r1)
                    {
                        break;
                    }
                }
                Console.WriteLine(y);
            }
        }
    }
}


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

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

         String [] arr = Console.ReadLine().Split(' ');

         Int64 k=int.Parse(arr[0]);
         Int64 b=int.Parse(arr[1]);
         Int64 n=int.Parse(arr[2]);
         Int64 t=int.Parse(arr[3]);

         Int64 x=1;

 for (n; n>0; )
 {

 x=k*x+b;

 if(x>t)
 {

 break;
 }
 else
 {
 dec(n);
 }

 }

  Console.WritwLine(n);

        }
    }

}


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

namespace CodeForce
{
    class _66a
    {
        public static void Main()
        {
            var line = Console.ReadLine();
            var big = BigInteger.Parse(line);
            if (big >= -128 && big <= 127)
            {
                Console.WriteLine("byte");
            }
            else if (big >= -32768 && big <= 32767)
            {
                Console.WriteLine("short");
            }
            else if (big >= -2147483648 && big <= 2147483647)
            {
                Console.WriteLine("int");
            }
            else if (big >= -9223372036854775808 && big <= 9223372036854775807)
            {
                Console.WriteLine("long");
            }
            else
            {
                Console.WriteLine("BigInteger");
            }
        }
    }
}


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

namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {
            long n;
            string res;
            n = long.Parse(Console.ReadLine());
            if (n >= - 9223372036854775808 && n <= 9223372036854775807)
                res = "long";
            else
                res = "BigInteger";
            if(n >= - 2147483648 && n <= 2147483647)
                res = "int";
            if(n >= -32768 && n <= 32768)
                res = "short";
            if(n >= -128 && n <= 127)
                res = "byte";

            Console.WriteLine(res);
        }
    }
}


using System;

namespace task_61_A
{
    class MainClass
    {
        public static void Main (string[] args)
        {
            long i;
            try
            {
                i=long.Parse(s);
            }
            catch (Exception ex)
            {
                Console.WriteLine("BigInteger");
                return;
            }

            if(i>-129 && i<128)
                    {
                Console.WriteLine("byte");
                return;
            }
            if(i>-32769 && i<32769)
            {
                Console.WriteLine("short");
                return;
            }
            if (i>=-2147483648 && i<=2147483647)
            {
                Console.WriteLine("int");
                return;
            }   //long
            if(i>=-9223372036854775808 && i<=9223372036854775807)
            {
                Console.WriteLine("long");
                return;
            }
            else
            {
                Console.WriteLine("BigInteger");
                return;
            }
        }
    }
}


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

namespace ConsoleApplication5
{
    class Program
    {
        static void Main(string[] args)
        {
            string n = Console.ReadLine();

            //double d = Convert.ToDouble(Convert.toi  n);

            Console.WriteLine(Checker(n));

            Console.ReadLine();
        }

        public static string Checker(string n)
        {

            string s = String.Empty;

            try
            {
                sbyte wert = Convert.ToSByte(n);    // (d >= -128.0 && d <= 127.0)
                s = "byte";
            }
            catch {}

            try
            {
                short wert = Convert.ToInt16(n);    // (d >= -32768.0 && d <= 32767.0)
                s = "short";
            }
            catch {}

            try
            {
                int wert = Convert.ToInt32(n);    // (d >= -2147483648.0 && d <= 2147483647.0)
                s = "int";
            }
            catch {}

            try
            {
                long wert = Convert.ToInt64(n);    // (d >= -9223372036854775808.0 && d <= 9223372036854775807.0)
                s = "long";
            }
            catch {}

            if (s == String.Empty)
            {
                s = "BigInteger";
            }

            return s;
        }
    }


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string buf;
            string[] arr = new string[3];
            int n = int.Parse(Console.ReadLine());
            int x = 0, y = 0, z = 0;
            for (int i = 0; i < n; i++)
            {
                buf = Console.ReadLine();
                arr = buf.Split(' ');
                x += int.Parse(arr[0]);
                y += int.Parse(arr[1]);
                z += int.Parse(arr[2]);
            }
            if (x == 0 && y == 0 && z == 0)
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
        }
    }
}


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

namespace PetyaJava
{
    static class Operacao
    {
        //Matriz de 5x4, sendo a primeira coluna o tipo de variável, e a segunda a informação se aquele tipo pode guardar o número informado
        static string[,] TipoDeVariavel = new string[,] { { "byte", "false" }, { "short", "false" },
            { "int", "false" }, { "long", "false" }, { "BigInteger", "false" } };

        public static void Compara(string valor)
        {
            //Usando o sistema de try catch, testar se o tipo de variável suporta o numero
            try
            {
                sbyte x = sbyte.Parse(valor); //Tentar fazer a conversão
                TipoDeVariavel[0, 1] = "true"; //Caso positivo, armazenar na matriz na celula correspondente
            }
            catch (System.Exception) //Testar outros tipos, em caso de erro
            {
                try
                {
                    short x = short.Parse(valor);
                    TipoDeVariavel[1, 1] = "true";
                }
                catch (System.Exception)
                {
                    try
                    {
                        int x = int.Parse(valor);
                        TipoDeVariavel[2, 1] = "true";
                    }
                    catch (System.Exception)
                    {
                        try
                        {
                            long x = long.Parse(valor);
                            TipoDeVariavel[3, 1] = "true";
                        }
                        //Se der erro em todas, ele guarda em BigInteger, visto que é o tipo que armazena números de qualquer tamanho
                        catch (System.Exception)
                        {
                            TipoDeVariavel[4, 1] = "true";
                        }
                    }
                }
            }

            for (int i = 0; i < 5; i++) //Percorrer a segunda coluna da matriz
            {
                if (TipoDeVariavel[i, 1] == "true") //O primeiro tipo que ela identificar já vai ser o resultado
                {
                    Console.Write(TipoDeVariavel[i, 0]);
                    return;
                }
            }
        }
    }
}


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

namespace Fibonacci_Freeza
{
    class Operacao
    {
        string num;

        public Operacao(string x) { num = x; }

        public string compara()
        {
            //    if (num.Length <= 3)
            //        return "byte";
            //    else
            //    {
            //        if (num.Length <= 5)
            //            return "short";
            //        else
            //        {
            //            if (num.Length <= 10)
            //                return "int";
            //            else
            //            {
            //                if (num.Length <= 19)
            //                    return "long";
            //                else
            //                    return "BigInteger";
            //            }
            //        }
            //    }
            try {
                sbyte x = sbyte.Parse(num);
                return "byte";
            }
            catch (System.Exception)
            {
                try {
                    short x = short.Parse(num);
                    return "short";
                }
                catch (System.Exception)
                {
                    try
                    {
                        int x = int.Parse(num);
                        return "int";
                    }
                    catch (System.Exception)
                    {
                        try
                        {
                            long x = long.Parse(num);
                            return "long";
                        }
                        catch (System.Exception)
                        {
                            return "BigInteger";
                        }
                    }
                }
            }

        }

    }
    class Program
    {
        static void Main(string[] args)
        {
            int escolha = 15;
            while (escolha == 15)
            {
                Operacao x = new Operacao(Console.ReadLine());
                Console.Write(x.compara());
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;

namespace Olymp
{
  public class ProblemSolver
  {
    private Tokenizer input;

    public void Solve()
    {
      int n = input.NextInt();
      long k = input.NextInt();
      if (k % 2 == 1)
      {
        Console.WriteLine(1);
      }
      else
      {
        long m = 1;
        int i = 1;
        while (m < k)
        {
          m = 2 * m + 1;
          ++i;
        }
        long l = 1;
        long r = m;
        int d = i;
        long c = (r - l) / 2 + 1;
        while (c != k)
        {
          if (c < k)
          {
            l = c;
          }
          else
          {
            r = c;
          }
          c = (r - l) / 2 + 1;
          --d;
        }
        Console.WriteLine(d);
      }
    }

    public ProblemSolver(TextReader input)
    {
      this.input = new Tokenizer(input);
    }
  }

  #region Service classes

  public class Tokenizer
  {
    private TextReader reader;

    public int NextInt()
    {
      var c = SkipWS();
      if (c == -1)
        throw new EndOfStreamException();
      bool isNegative = false;
      if (c == '-' || c == '+')
      {
        isNegative = c == '-';
        c = this.reader.Read();
        if (c == -1)
          throw new InvalidOperationException();
      }
      if (!char.IsDigit((char)c))
        throw new InvalidOperationException();
      int result = (char)c - '0';
      c = this.reader.Read();
      while (c > 0 && !char.IsWhiteSpace((char)c))
      {
        if (!char.IsDigit((char)c))
          throw new InvalidOperationException();
        result = result * 10 + (char)c - '0';
        c = this.reader.Read();
      }
      if (isNegative)
        result = -result;
      return result;
    }

    public string ReadLine()
    {
      return reader.ReadLine();
    }

    public long NextLong()
    {
      return long.Parse(this.NextToken());
    }

    public double NextDouble()
    {
      return double.Parse(this.NextToken(), CultureInfo.InvariantCulture);
    }

    public int[] ReadIntArray(int n)
    {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = NextInt();
      return a;
    }

    public long[] ReadLongArray(int n)
    {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = NextLong();
      return a;
    }

    public double[] ReadDoubleArray(int n)
    {
      double[] a = new double[n];
      for (int i = 0; i < n; i++)
        a[i] = NextDouble();
      return a;
    }

    public string NextToken()
    {
      var c = SkipWS();
      if (c == -1)
        return null;
      var sb = new StringBuilder();
      while (c > 0 && !char.IsWhiteSpace((char)c))
      {
        sb.Append((char)c);
        c = this.reader.Read();
      }
      return sb.ToString();
    }

    private int SkipWS()
    {
      int c = this.reader.Read();
      if (c == -1)
        return c;
      while (c > 0 && char.IsWhiteSpace((char)c))
        c = this.reader.Read();
      return c;
    }

    public Tokenizer(TextReader reader)
    {
      this.reader = reader;
    }
  }

  class Program
  {
    public static void Main(string[] args)
    {
      var solver = new ProblemSolver(Console.In);
      solver.Solve();
    }
  }

  #endregion
}


using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
class Problem
{
    static void Main()
    {
        //--------------------------------input--------------------------------//

        int n = Convert.ToInt32( Console.ReadLine() );
        var a = Array.ConvertAll( Console.ReadLine().Split(), Convert.ToInt32 );
        var b = Array.ConvertAll( Console.ReadLine().Split(), Convert.ToInt32 );

        //--------------------------------solve--------------------------------/

        int sum = a.Sum();
        sum -= b.Sum();
        if(sum == 0)
            Console.WriteLine( "Yes" );
        else
            Console.WriteLine( "No" );

    }

}


using System;
class Program
{
    static void Main()
    {
        int n = Convert.ToInt32(Console.ReadLine());
        int[] Fday = Array.ConvertAll(Console.ReadLine().Split(), Convert.ToInt32);
        int[] Sday = Array.ConvertAll(Console.ReadLine().Split(), Convert.ToInt32);
        int sum0 = 0, sum1 = 0;
        foreach (int i in Fday)
        {
            sum0 += i;
        }
        foreach (int i in Sday)
        {
            sum1 += i;
        }
        Console.WriteLine(sum0 <= sum1 ? "Yes" : "No");
    }
}


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

namespace Codeforces
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine();

            long x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6;

            x1 = long.Parse(line.Split(' ')[0]);
            y1 = long.Parse(line.Split(' ')[1]);
            x2 = long.Parse(line.Split(' ')[2]);
            y2 = long.Parse(line.Split(' ')[3]);

            line = Console.ReadLine();

            x3 = long.Parse(line.Split(' ')[0]);
            y3 = long.Parse(line.Split(' ')[1]);
            x4 = long.Parse(line.Split(' ')[2]);
            y4 = long.Parse(line.Split(' ')[3]);

            line = Console.ReadLine();
            x5 = long.Parse(line.Split(' ')[0]);
            y5 = long.Parse(line.Split(' ')[1]);
            x6 = long.Parse(line.Split(' ')[2]);
            y6 = long.Parse(line.Split(' ')[3]);

            long area1 = 0, area2 = 0, area3 = 0;

            if (x3 <= x1)
            {
                x3 = x1;
            }

            if (x4 >= x2)
            {
                x4 = x2;
            }

            if (y3 <= y1)
            {
                y3 = y1;
            }

            if (y4 >= y2)
            {
                y4 = y2;
            }

            if (x3 <= x4 && y3 <= y4)
            {
                area2 = (x4 - x3) * (y4 - y3);
            }

            if (x5 <= x1)
            {
                x5 = x1;
            }

            if (x6 >= x2)
            {
                x6 = x2;
            }

            if (y5 <= y1)
            {
                y5 = y1;
            }

            if (y6 >= y2)
            {
                y6 = y2;
            }

            if (x5 <= x6 && y5 <= y6)
            {
                area3 = (x6 - x5) * (y6 - y5);
            }

            var result = false;

           if (x1 == x3 && y1 == y3 && x2 == x4 && y2 == y4)
           {
                result = true;
           }
           else if (x1 == x5 && y1 == y5 && x2 == x6 && y2 == y6)
            {
                result = true;
            }
           else if (area2 == 0 || area3 == 0)
        {
                result = false;
        }
        else if (area2 > 0 && area3 > 0 &&  ((x4-x3 + x6-x5) >= (x2-x1)) && y1 == y3 && y2 == y4 && y1 == y5 && y2 == y6)
            {
                result = true;
            }
           else if (area2 > 0 && area3 > 0 && ((y4 - y3 + y6 - y5) >= (y2 - y1)) && x1 == x3 && x2 == x4 && x1 == x5 && x2 == x6)
            {
                result = true;
            }

            Console.WriteLine(!result ? "YES" : "NO");

        }

    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using SB = System.Text.StringBuilder;
//using System.Threading.Tasks;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
using System.Numerics;
using static System.Math;
using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    readonly Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
    readonly int dom = 998244353;
    bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
    bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (b.CompareTo(a) < 0) { a = b; return true; } return false; }

    void solve()
    {
        int N = cin.nextint;
        int T = cin.nextint;

        var A = new int[N];
        var G = new int[N];

        for (int i = 0; i < N; i++)
        {
            A[i] = cin.nextint;
            G[i] = cin.nextint - 1;
        }

        ModInt ans = 0;
        for (int S = 0; S < 1 << N; S++)
        {
            int time = 0;
            var type = new int[3];
            for (int i = 0; i < N; i++)
            {
                if ((S >> i & 1) == 1)
                {
                    time += A[i];
                    type[G[i]]++;
                }
            }
            if (time != T)
            {
                continue;
            }
            int X = type[0];
            int Y = type[1];
            int Z = type[2];

            var dp = new long[type[0] + 1, type[1] + 1, type[2] + 1, 4];

            for (int i = 0; i <= X; i++)
            {
                for (int j = 0; j <= Y; j++)
                {
                    for (int k = 0; k <= Z; k++)
                    {
                        for (int l = 0; l < 4; l++)
                        {
                            dp[i, j, k, l] = -1;
                        }
                    }
                }
            }
            var ret = calc(X, Y, Z, 3, dp);
            if (X > 1) ret = ret * X;
            if (Y > 1) ret = ret * Y;
            if (Z > 1) ret = ret * Z;
            ans += ret % mod;

        }
        WriteLine(ans);
    }

    long calc(int x, int y, int z, int before, long[,,,] dp)
    {
        //WriteLine(x + " " + y + " " + z);
        if (dp[x, y, z, before] >= 0)
        {
            return dp[x, y, z, before];
        }
        if (x == 0 && y == 0 && z == 0)
        {
            return 1;
        }

        long ret = 0;
        if (x > 0 && before != 0)
        {
            ret += calc(x - 1, y, z, 0, dp);
        }
        if (y > 0 && before != 1)
        {
            ret += calc(x, y - 1, z, 1, dp);
        }
        if (z > 0 && before != 2)
        {
            ret += calc(x, y, z - 1, 2, dp);
        }
        ret %= mod;
        return dp[x, y, z, before] = ret;
    }

}

/// <summary>
/// [0,<see cref="Mod"/>) までの値を取るような数
/// </summary>
/// <OriginalAuthor>camypaper</OriginalAuthor>
struct ModInt
{
    /// <summary>
    /// 剰余を取る値．
    /// </summary>
    public const long Mod = (int)1e9 + 7;

    /// <summary>
    /// 実際の数値．
    /// </summary>
    public long num;
    /// <summary>
    /// 値が <paramref name="n"/> であるようなインスタンスを構築します．
    /// </summary>
    /// <param name="n">インスタンスが持つ値</param>
    /// <remarks>パフォーマンスの問題上，コンストラクタ内では剰余を取りません．そのため，<paramref name="n"/> ∈ [0,<see cref="Mod"/>) を満たすような <paramref name="n"/> を渡してください．このコンストラクタは O(1) で実行されます．</remarks>
    public ModInt(long n) { num = n; }
    /// <summary>
    /// このインスタンスの数値を文字列に変換します．
    /// </summary>
    /// <returns>[0,<see cref="Mod"/>) の範囲内の整数を 10 進表記したもの．</returns>
    public override string ToString() { return num.ToString(); }
    public static ModInt operator +(ModInt l, ModInt r) { l.num += r.num; if (l.num >= Mod) l.num -= Mod; return l; }
    public static ModInt operator -(ModInt l, ModInt r) { l.num -= r.num; if (l.num < 0) l.num += Mod; return l; }
    public static ModInt operator *(ModInt l, ModInt r) { return new ModInt(l.num * r.num % Mod); }
    public static implicit operator ModInt(long n) { n %= Mod; if (n < 0) n += Mod; return new ModInt(n); }

    /// <summary>
    /// 与えられた 2 つの数値からべき剰余を計算します．
    /// </summary>
    /// <param name="v">べき乗の底</param>
    /// <param name="k">べき指数</param>
    /// <returns>繰り返し二乗法により O(N log N) で実行されます．</returns>
    public static ModInt Pow(ModInt v, long k) { return Pow(v.num, k); }

    /// <summary>
    /// 与えられた 2 つの数値からべき剰余を計算します．
    /// </summary>
    /// <param name="v">べき乗の底</param>
    /// <param name="k">べき指数</param>
    /// <returns>繰り返し二乗法により O(N log N) で実行されます．</returns>
    public static ModInt Pow(long v, long k)
    {
        long ret = 1;
        for (k %= Mod - 1; k > 0; k >>= 1, v = v * v % Mod)
            if ((k & 1) == 1) ret = ret * v % Mod;
        return new ModInt(ret);
    }
    /// <summary>
    /// 与えられた数の逆元を計算します．
    /// </summary>
    /// <param name="v">逆元を取る対象となる数</param>
    /// <returns>逆元となるような値</returns>
    /// <remarks>法が素数であることを仮定して，フェルマーの小定理に従って逆元を O(log N) で計算します．</remarks>
    public static ModInt Inverse(ModInt v) { return Pow(v, Mod - 2); }
}

class BinomialCoefficient
{
    public ModInt[] fact, ifact;
    /// <summary>
    /// <paramref name="n"/>は <paramref name="Mod"/>未満でお願いします。
    /// </summary>
    /// <param name="n"></param>
    public BinomialCoefficient(ModInt _n)
    {
        int n = (int)_n.num;
        fact = new ModInt[n + 1];
        ifact = new ModInt[n + 1];
        fact[0] = 1;
        for (int i = 1; i <= n; i++)
            fact[i] = fact[i - 1] * i;
        ifact[n] = ModInt.Inverse(fact[n]);
        for (int i = n - 1; i >= 0; i--)
            ifact[i] = ifact[i + 1] * (i + 1);
        ifact[0] = ifact[1];
    }
    public ModInt this[int n, int r]
    {
        get
        {
            if (n < 0 || n >= fact.Length || r < 0 || r > n) return 0;
            return fact[n] * ifact[n - r] * ifact[r];
        }
    }
    public ModInt RepeatedCombination(int n, int k)
    {
        if (k == 0) return 1;
        return this[n + k - 1, k];
    }
}

static class Ex
{
    public static void join<T>(this IEnumerable<T> values, string sep = " ") => WriteLine(string.Join(sep, values));
    public static string concat<T>(this IEnumerable<T> values) => string.Concat(values);
    public static string reverse(this string s) { var t = s.ToCharArray(); Array.Reverse(t); return t.concat(); }

    public static int lower_bound<T>(this IList<T> arr, T val) where T : IComparable<T>
    {
        int low = 0, high = arr.Count;
        int mid;
        while (low < high)
        {
            mid = ((high - low) >> 1) + low;
            if (arr[mid].CompareTo(val) < 0) low = mid + 1;
            else high = mid;
        }
        return low;
    }
    public static int upper_bound<T>(this IList<T> arr, T val) where T : IComparable<T>
    {
        int low = 0, high = arr.Count;
        int mid;
        while (low < high)
        {
            mid = ((high - low) >> 1) + low;
            if (arr[mid].CompareTo(val) <= 0) low = mid + 1;
            else high = mid;
        }
        return low;
    }
}

class Pair<T, U> : IComparable<Pair<T, U>> where T : IComparable<T> where U : IComparable<U>
{
    public T f; public U s;
    public Pair(T f, U s) { this.f = f; this.s = s; }
    public int CompareTo(Pair<T, U> a) => f.CompareTo(a.f) != 0 ? f.CompareTo(a.f) : s.CompareTo(a.s);
    public override string ToString() => $"{f} {s}";
}

class Scanner
{
    string[] s; int i;
    readonly char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan => ReadLine().Split();
    public int[] scanint => Array.ConvertAll(scan, int.Parse);
    public long[] scanlong => Array.ConvertAll(scan, long.Parse);
    public double[] scandouble => Array.ConvertAll(scan, double.Parse);
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint => int.Parse(next);
    public long nextlong => long.Parse(next);
    public double nextdouble => double.Parse(next);
}


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

namespace ProblemSets
{
    using System;
    using System.Collections.Generic;
    using System.Collections;
    using System.Linq;
    using System.Text;

    namespace LongPath
    {
        public class Problem420b
        {
            public static void Main(string[] args)
            {
                var input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                var numberOfPeople = input[0];
                var numberOfMessage = input[1];
                var employees = new int[100000 + 1];

                for (int i = 1; i <= numberOfPeople; i++)
                {
                    employees[i] = 99;
                }

                var NotALeader = new ArrayList();

                for (int i = 0; i < numberOfMessage; i++)
                {

                    var status = Console.ReadLine().Split(' ');
                    var symbol = status[0][0];
                    var id = int.Parse(status[1]);

                    if (symbol == '+')
                    {
                        for (int j = 1; j <= numberOfPeople; j++)
                        {
                            if (j == id) continue;
                            if (employees[j] == 1)
                            {
                                NotALeader.Add(id);
                            }
                            if (employees[j] == 0)
                            {
                NotALeader.Add(j);
                            }
                        }
                        employees[id] = 1;
                   }

                    if (symbol == '-')
                    {
                        var prevStatusOfEmployee = employees[id];

                        if (prevStatusOfEmployee == 1)
                        {

                            for (int j = 1; j <= numberOfPeople; j++)
                            {
                                if (j == id) continue;
                                if (employees[j] == 1 || employees[j]== 0)
                                {
                                    NotALeader.Add(id);
                                }
                            }
                        }
                        else if (prevStatusOfEmployee == 99)
                        {
                            for (int j = 1; j <= numberOfPeople; j++)
                            {
                                if (j == id) continue;
                                if (employees[j] == 1)
                                {
                                    NotALeader.Add(id);
                                    NotALeader.Add(j);
                                }
                            }
                        }

                        employees[id] = 0;
                    }
                    lastEmployeeID = id;
                }

                var leaders = new ArrayList();
                for (int i = 1; i <= numberOfPeople; i++)
                {

                    if (employees[i] == 99 || employees[i] == 1)
                    {
                        if (!NotALeader.Contains(i)) leaders.Add(i);
                    }
                    else if (!NotALeader.Contains(i)) leaders.Add(i);
                }

                var numberOfLeader = leaders.Count;
                Console.WriteLine(numberOfLeader);

                foreach (var leader in leaders)
                {
                    Console.Write(leader);
                    Console.Write(" ");
                }

            }
        }
    }

}


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

namespace LongPath
{
    public class Problem420b
    {
        public static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var numberOfPeople = input[0];
            var numberOfMessage = input[1];
            var employees = new int[100000];

            for (int i = 0; i < numberOfPeople; i++)
            {
                employees[i] = 99;
            }

            var NotALeader = new ArrayList();
            for (int i = 0; i < numberOfMessage; i++)
            {
                var  status = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                var symbol = status[0];
                var id = status[1];
                if (symbol == '+') employees[id] = 1;

                if (symbol == '-')
                {
                    employees[id] = 0;
                    for (int j = 0; j < numberOfPeople; j++)
                    {
                        if (employees[j] == 1)
                        {
                            NotALeader.Add(id);
                        }
                    }
                }
            }

            var leaders = new ArrayList();
            for (int i = 0; i < numberOfPeople; i++)
            {

                if (employees[i] == 99)
                {
                    leaders.Add(i);
                }
                else if (!NotALeader.Contains(i))
                {
                    leaders.Add(i);
                }
            }

        }
    }
}


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

namespace ProblemSets
{
    using System;
    using System.Collections.Generic;
    using System.Collections;
    using System.Linq;
    using System.Text;

    namespace LongPath
    {
        public class Problem420b
        {
            public static void Main(string[] args)
            {
                var input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                var numberOfPeople = input[0];
                var numberOfMessage = input[1];
                Dictionary<int, int> employees = new Dictionary<int,int>();

                var NotALeader = new ArrayList();

                int lastPersonId = -1;
                for (int i = 0; i < numberOfMessage; i++)
                {

                    var status = Console.ReadLine().Split(' ');
                    var symbol = status[0][0];
                    var id = int.Parse(status[1]);

                    if (symbol == '+')
                    {
                        foreach (var pair in employees)
                        {
                            if (pair.Key == id) continue;
                            // if others joined before me, I am not a leader
                            if (pair.Value == 1)
                            {
                                NotALeader.Add(id);
                            }
                            // if other people joined and logged out before me, they are not a leader.
                            // I am also not a leader unless I just logged out and logging back in
                            if (pair.Value == 0)
                            {
                                NotALeader.Add(pair.Key);
                                if (lastPersonId != id) NotALeader.Add(id);
                            }
                        }
                        employees[id] = 1;
                    }

                    if (symbol == '-')
                    {
                        bool havePreviousRecord = employees.ContainsKey(id);

                        // when I am logging out, if others are still logged in, i am not a leader
                        foreach (var pair in employees)
                        {
                            if (pair.Key == id) continue;
                            if (pair.Value == 1)
                            {
                                NotALeader.Add(id);
                            }
                            // if I have no record of me joining, then other who logged in (or logged in and out) after me are not a leader
                            if (!havePreviousRecord)
                            {
                                if (pair.Value == 1 || pair.Value == 0) NotALeader.Add(pair.Key);
                            }
                        }

                        employees[id] = 0;
                    }
                    lastPersonId = id;
                }

                var leaders = new ArrayList();
                for (int i = 1; i <= numberOfPeople; i++)
                {
                    if (!NotALeader.Contains(i)) leaders.Add(i);
                }

                var numberOfLeader = leaders.Count;
                Console.WriteLine(numberOfLeader);

                foreach (var leader in leaders)
                {
                    Console.Write(leader);
                    Console.Write(" ");
                }

            }
        }
    }

}


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

namespace Problems
{
    public class Problem420B
    {
        public static void Main(string[] args)
        {
            var nm = Console.ReadLine().Split(' ');
            var n = int.Parse(nm[0]);
            var m = int.Parse(nm[1]);

            var notLeaders = new bool[n];
            var present = new HashSet<int>();
            var absent = new HashSet<int>();

            int lastpersonToLeave = 0;
            for (int i = 0; i < m; i++)
            {
                var msg = Console.ReadLine().Split(' ');
                var action = msg[0][0];
                var id = int.Parse(msg[1]);

                if (action == '+')
                {
                    if (present.Count > 0)
                    {
                        // Not the first guy to be in the session
                        notLeaders[id - 1] = true;
                    }

                    present.Add(id);
                    absent.Remove(id);

                    if (lastpersonToLeave != 0 && lastpersonToLeave != id)
                    {
                        // Other people have left when current guy was absent
                        // current guy is not leader
                        notLeaders[id - 1] = true;
                    }

                    // Anyone who is absent cannot be leader,
                    // because they are certainly not here when a new person is joining
                    foreach (var absentee in absent)
                    {
                        notLeaders[absentee - 1] = true;
                    }

                    absent = new HashSet<int>();
                }
                else
                {
                    lastpersonToLeave = id;

                    // Means anyone who is present now joined after current guy joined
                    // None of them can be leader
                    if (!present.Contains(id))
                    {
                        foreach (var presented in present)
                        {
                            notLeaders[presented - 1] = true;
                        }
                    }

                    present.Remove(id);

                    // Other people are present when current guy left
                    // Current guy cannot be leader
                    if (present.Count > 0)
                    {
                        notLeaders[id - 1] = true;
                    }

                    // Anyone who is absent for sure cannot be leader,
                    // because they are for sure nto the last person to leave the room
                    foreach (var absentee in absent)
                    {
                        notLeaders[absentee - 1] = true;
                    }

                    absent = new HashSet<int>();
                    absent.Add(id);
                }
            }

            var k = notLeaders.Sum(notLeader => notLeader ? 0 : 1);
            Console.WriteLine(k);

            for (int i = 0; i < n; i++)
            {
                if (!notLeaders[i])
                {
                    Console.Write("{0} ", i + 1);
                }
            }
        }
    }
}


using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		long N = long.Parse(str[0]);
		long M = long.Parse(str[1]);
		long ct = 0;
		for(var i=1;i<=M;i++){
			for(var j=1;j<=M;j++){
				if((i*i+j*j)%M==0){
					ct += 1;
				}
			}
		}
		long ans = (N/M)*(N/M)*ct;
		long ct2 = 0;
		for(var i=1;i<=M;i++){
			for(var j=1;j<=N%M;j++){
				if((i*i+j*j)%M==0){
					ct2 += 1;
				}
			}
		}
		ans += ct2 * 2;
		long ct3 = 0;
		for(var i=1;i<=N%M;i++){
			for(var j=1;j<=N%M;j++){
				if((i*i+j*j)%M==0){
					ct3 += 1;
				}
			}
		}
		ans += ct3;
		Console.Write(ans);
	}
}


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

namespace ConsoleApplication5
{
    class Program
    {

        static void Main()
        {
            string[] vrem = Console.ReadLine().Split(':');
            char[] a = new char[5];
            char[] b = new char[5];
            int[] a1 = new int[5];
            int[] b1 = new int[5];

            for (int i = vrem[0].Length - 1; i >= 0; i--)
            {
                a[vrem[0].Length - 1 - i] = vrem[0][i];
                if (a[vrem[0].Length - 1 - i] >= 65 && a[vrem[0].Length - 1 - i] <= 90)
                    a1[vrem[0].Length - 1 - i] = Convert.ToInt32(a[vrem[0].Length - 1 - i] - 55);
                else
                    a1[vrem[0].Length - 1 - i] = Convert.ToInt32(a[vrem[0].Length - 1 - i] - 48);
            }
            for (int i = vrem[1].Length - 1; i >= 0; i--)
            {
                b[vrem[1].Length - 1 - i] = vrem[1][i];
                if (b[vrem[1].Length - 1 - i] >= 65 && b[vrem[1].Length - 1 - i] <= 90)
                    b1[vrem[1].Length - 1 - i] = Convert.ToInt32(b[vrem[1].Length - 1 - i] - 55);
                else
                    b1[vrem[1].Length - 1 - i] = Convert.ToInt32(b[vrem[1].Length - 1 - i] - 48);
            }

            int max = 0;
            for (int i = 0; i < a1.Length; i++)
            {
                if (max < a1[i])
                    max = a1[i];
                if (max < b1[i])
                    max = b1[i];
            }

            int[] otvet = new int[60];
            int k = max;

                double q = 0;
                double w = 0;
                while (k < 61)
                {
                    k++;
                    q = 0;
                    w = 0;
                    for (int i = a1.Length - 1; i >= 0; i--)
                        q = q + a1[i] * Math.Pow(k, i);

                    for (int i = b1.Length - 1; i >= 0; i--)
                        w = w + b1[i] * Math.Pow(k, i);

                    if (q <= 23 && w <= 59)
                        otvet[k-1] = k;
                    else
                        break;
                }

                if (k == 600)
                    Console.WriteLine("-1");
                else if (k == max + 1)
                    Console.WriteLine("0");
                else
                {
                    for (int i = 0; i < otvet.Length; i++)
                        if (otvet[i] != 0)
                            Console.Write(otvet[i] + " ");
                }

        }
    }
}


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

namespace CF526A {
    class Program {
        static void Main(string[] args) {
            int seg = int.Parse(Console.ReadLine());
            char[] segments = new char[seg];
            List<int> platPos = new List<int>();

            for(int i = 0; i < seg; i++) {
                char segType = (char)Console.Read();
                if(segType == '*') {
                    platPos.Add(i);
                }
                segments[i] = segType;
            }

            bool isPossible = false;
            for(int i = 0, startPlat = platPos[i]; i < platPos.Count - 4; i++, startPlat = platPos[i]) {
                for(int jump = 1; jump < seg; jump++) {
                    int count = 1;
                    //Console.WriteLine("Jumplength = " + jump);
                    for(int j = 1; startPlat + j*jump < seg; j++) { //index through segments by jump length from given platform
                        //Console.WriteLine("Jumped to pos " + (startPlat + j * jump) + " found " + segments[startPlat + j * jump]);
                        if(segments[startPlat + j*jump] == '*') {
                            count++;
                        } else {
                            j = seg;
                        }
                    }
                    if(count >= 5) {
                        isPossible = true;
                        jump = seg;
                        i = platPos.Count - 4;
                    }
                }
            }

            if(isPossible) {
                Console.WriteLine("yes");
            } else {
                Console.WriteLine("no");
            }
        }
    }
}


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

namespace Codeforces
{
	class Program
	{
		static void Main(string[] args)
		{
			string input1 = Console.ReadLine();
			//string input2 = Console.ReadLine();

			//var inputs1 = input1.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
			//var inputs2 = input2.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();

			var input = input1;
			var words = new List<string>();
			int index = -1;
			while (input.Length > 0)
			{
				index = input.IndexOf("WUB");
				switch (index)
				{
					case -1:
						words.Add(input);
						break;
					case 0:
						input = input.Substring(3);
						break;
					default:
						words.Add(input.Substring(0, index));
						input = input.Substring(index);
						break;
				}
			}

			Console.WriteLine(words.Aggregate((a, b) => $"{a} {b}"));
		}

		//private static long GCD(long a, long b)
		//{
		//	long max = Math.Max(a, b);
		//	long min = Math.Min(a, b);

		//	if (min == 0)
		//	{
		//		return max;
		//	}

		//	a = min;
		//	b = max % min;
		//	return GCD(a, b);
		//}

		//private static long LCM(long a, long b)
		//{
		//	return Math.Abs(a * b) / GCD(a, b);
		//}

		//private static int Length(short[] a)
		//{
		//	int firstItemIndex = 0;
		//	for (int i = 0; i < a.Length; i++)
		//	{
		//		if (a[i] == 0)
		//		{
		//			continue;
		//		}

		//		firstItemIndex = i;
		//		break;
		//	}

		//	return a.Length - firstItemIndex;
		//}

		//private static short[] Subtract(short[] a, short[] b)
		//{
		//	if (a.Length != b.Length)
		//	{
		//		throw new ArgumentException();
		//	}

		//	short[] result = new short[a.Length];
		//	Array.Copy(a, result, a.Length);
		//	for (int i = result.Length - 1; i >= 0; i--)
		//	{
		//		if (result[i] < b[i])
		//		{
		//			int j = i - 1;
		//			while (result[j] == 0)
		//			{
		//				result[j--] = 9;
		//			}

		//			result[j]--;
		//			result[i] += 10;
		//		}

		//		result[i] -= b[i];
		//	}

		//	return result;
		//}

		//private static short[] Multiply(short[] a, int b)
		//{
		//	short[] result = new short[a.Length];
		//	for (int i = a.Length - 1; i > 0; i--)
		//	{
		//		int temp = a[i] * b;
		//		result[i] = (short)(result[i] + temp % 10);
		//		result[i - 1] = (short)(result[i - 1] + temp / 10);
		//	}

		//	return result;
		//}

		//private static int Mod(short[] a, int b)
		//{
		//	int rest = 0, i = 0;
		//	while (i < a.Length)
		//	{
		//		int d = 10 * rest + a[i];
		//		while (d < b && i < a.Length - 1)
		//		{
		//			d = 10 * d + a[++i];
		//		}

		//		rest = d % b;
		//		i++;
		//	}

		//	return rest;
		//}

		//private static short[] Divide(short[] a, int b)
		//{
		//	short[] result = new short[a.Length];
		//	int rest = 0, i = 0;
		//	while (i < a.Length)
		//	{
		//		int d = 10 * rest + a[i];
		//		while (d < b && i < a.Length - 1)
		//		{
		//			d = 10 * d + a[++i];
		//		}

		//		result[i] = (short)(d / b);
		//		rest = d % b;
		//		i++;
		//	}

		//	return result;
		//}
	}
}


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

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

            string Input1;
            Input1 = Console.ReadLine();
            string[] split = Input1.Split(' ');
            int n, m, output=0;
            n = Convert.ToInt32(split[0]);
            m = Convert.ToInt32(split[1]);
            double x=0;

                if (m > n) {
                    Console.WriteLine("-1");
                }
                else
                {
                  x= m*2;
                  x=n/m;
                  x=Math.Ceiling(x);
                  Console.writeLine(x);
                }

        }

    }
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#include <random>
#include <climits>
#include <iomanip>
#include <queue>
#include <bitset>
#include <cctype>

using namespace std;

#define forn(i,n) for (int i = 0;i < int(n);i++)
#define ford(i,n) for (int i = n-1;i >=0;i--)
#define fore(i,l,r) for (int i = int(l);i < int(r);i++)
#define forv(a) for(int i = 0;i < (a).size();i++) cin >> a[i]
#define correct(x,n) (((x) >= 0) && ((x) < n))
#define sort_all(a) sort((a).begin(),(a).end())
#define mp(a,b) make_pair((a),(b))
#define all(a) (a).begin(),(a).end()
#define pb(a) push_back(a)
#define rnd() (rand() + (RAND_MAX+1)*rand())
#define fi first
#define se second
#define V(A) vector<A>
//#define DEBUG_

//#define x first
//#define y second

typedef long long li;
typedef vector<int> vi;
typedef vector<li> vli;
typedef pair<int, int> pi;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
typedef vector<vli> vvli;
typedef long double ld;
typedef pair<li, li> Point;

const ld Eps = 1e-9;

vector<pair<li, li>> fact(li b)
{
	vector<pair<li, li>> res;
	for (li i = 2; i*i <= b; i++)
	{
		if (b % i != 0)
			continue;
		res.push_back(mp(i, 0));
		while (b % i == 0)
		{
			b /= i;
			res.back().second++;
		}
	}

	if (b != 1)
		res.push_back(mp(b, 1));

	return res;
}

int main()
{
	//freopen("in.txt", "r", stdin);
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	li n, b;
	cin >> n >> b;
	vector<pair<li, li>> a = fact(b);

	li mn = 2000000000000000000;

	for (auto pr : a)
	{
		li p = pr.first;
		li k = pr.second;
		li pw = 0;
		for (li n1 = n / p; n1 > 0; n1 /= p)
			pw += n1;
		mn = min(mn, pw / k);
	}

	cout << mn << endl;
}


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

namespace VaniaAndLight
{
    class Program
    {
        static void Main(string[] args)
        {
            int x, y, z, a, b, c;
            string[] arrayXYZ = Console.ReadLine().Split(new char[] { ' '}, StringSplitOptions.RemoveEmptyEntries);
            string[] arrayABC = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            x = int.Parse(arrayXYZ[0]);
            y = int.Parse(arrayXYZ[1]);
            z = int.Parse(arrayXYZ[2]);
            a = int.Parse(arrayABC[0]);
            b = int.Parse(arrayABC[1]);
            c = int.Parse(arrayABC[2]);

            if (x > a)
            {
                Console.WriteLine("NO");
                return;
            }
            else
            {
                a -= x;
            }

            if (y > (a + b))
            {
                Console.WriteLine("NO");
                return;
            }
            else
            {
                if (y - a > 0)
                {
                    y -= a;
                    a = 0;
                    b -= y;
                }
                else
                {
                    a -= y;
                }
            }

            if (z > (a + b + c))
            {
                Console.WriteLine("NO");
                return;
            }
            else
            {
                Console.WriteLine("YES");
            }
        }

        static int rank(int key, int[] a)
        {
            int lo = 0;
            int hi = a.Length;

            while (lo <= hi)
            {
                int mid = lo + (hi - lo) / 2;
                if (key < a[mid])
                {
                    hi = mid - 1;
                }
                else if (key > a[mid])
                {
                    lo = mid + 1;
                }
                else
                {
                    return mid;
                }
            }
            return -1;
        }
    }
}


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

namespace CodeForcesProblems.A
{
    class A111_Got_Any_Grapes
    {
        public static void Main()
        {
            while(true)
            {
                string[] a = Console.ReadLine().Split(' ');
                int A = int.Parse(a[0]);
                int D = int.Parse(a[1]);
                int M = int.Parse(a[2]);
                a = Console.ReadLine().Split(' ');
                int g = int.Parse(a[0]);
                int p = int.Parse(a[1]);
                int b = int.Parse(a[2]);
                bool f = true;
                if (A <= g)
                    g -= A;
                else
                    f = false;
                g += p;
                if (D <= g)
                    g -= D;
                else
                    f = false;
                g += b;

                if (M > g)
                    f = false;
                if(f)
                    Console.WriteLine("YES");
                else
                    Console.WriteLine("NO");
            }
        }
    }
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c,x,y,z;
            a = Convert.ToInt16(Console.ReadLine());
            b = Convert.ToInt16(Console.ReadLine());
            c = Convert.ToInt16(Console.ReadLine());
            x = Convert.ToInt16(Console.ReadLine());
            y = Convert.ToInt16(Console.ReadLine());
            z = Convert.ToInt16(Console.ReadLine());
            if (a <= x)
            {
                x -= a;
                if (b <= x + y)
                {
                    if (x >= b)
                    {
                        x -= b;
                    }
                    else
                    {
                        if (y >= b)
                        {
                            y -= b;
                        }
                        else
                        {
                            x -= b;
                            b = 0;
                            y -= b;
                            if (c <= x + y + z)
                                Console.WriteLine("YES");
                            else
                                Console.WriteLine("No");
                        }
                    }

                }
                else
                    Console.WriteLine("NO");
            }
            else
                Console.WriteLine("NO");
        }
    }
}


public class Problem

static void Main()
{
	if (Eat())
		Console.WriteLine("YES");
	else
		Console.WriteLine("NO");

}

static bool Eat()
{
	var s1 = Console.ReadLine();
	var s2 = Console.ReadLine();
	var toEats = s1.Split(' ').Select(s => int.Parse(s)).ToArray();
	var grapes = s2.Split(' ').Select(s => int.Parse(s)).ToArray();
	var andrew = toEats[0];
	var dmitry = toEats[1];
	var michael = toEats[2];

	var green = grapes[0];
	var purple = grapes[1];
	var black = grapes[2];

	if (andrew > green) return false;
	green = green - andrew;

	if (dmitry > green + purple) return false;
	if (michael > black + (green + purple) - dmitry) return false;
	return true;
}
}


using System;
using System.Linq;

namespace ACM
{
    class Program
    {
        static void Main()
        {
            var input = Console.ReadLine();
            var a = input.Count(c => c == '-');
            var b = input.Count(c => c == 'o');
            Console.WriteLine(a % b == 0 ? "YES" : "NO");
        }
    }
}


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

namespace Codeforces
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int numbLink = 0, numbPearl = 0;
            foreach (char c in s)
            {
                if (c == '-') numbLink++;
                else numbPearl ++;
            }
            if(numbLink % numbPearl == 0)
            {
                Console.WriteLine("YES");
            }else
            {
                Console.WriteLine("NO");
            }
            //Console.ReadKey();
        }
    }
}


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

namespace Codeforces
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int numbLink = 0, numbPearl = 0;
            foreach (char c in s)
            {
                if (c == '-') numbLink++;
                else numbPearl ++;
            }
            if(numbLink % numbPearl == 0)
            {
                Console.WriteLine("YES");
            }else
            {
                Console.WriteLine("NO");
            }
=
        }
    }
}


using System;
 public class Program
    {
        public static void Main(string[] args)
        {
            int[] aClassCounter, bClassCounter;
            {
                string[] input = Console.In.ReadToEnd().Split(new char[] { '\r', '\n', ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
                aClassCounter = new int[6];
                bClassCounter = new int[6];
                for(int i = 1, j = int.Parse(input[0])+1; j<input.Length; ++i, ++j)
                {
                    aClassCounter[int.Parse(input[i])]++;
                    bClassCounter[int.Parse(input[j])]++;
                }
            }
            for(int i = 1; i<6; ++i)
            {
                if (aClassCounter[i] == bClassCounter[i])
                    continue;
                if(aClassCounter[i]>bClassCounter[i])
                {
                    if ((aClassCounter[i] - bClassCounter[i]) % 2 == 0)
                        aClassCounter[0] += (aClassCounter[i] - bClassCounter[i]) / 2;
                    else { aClassCounter[0]=-1; break; }
                }
                else
                {
                    if ((bClassCounter[i] - aClassCounter[i]) % 2 ==1)
                    { aClassCounter[0] = -1; break;}
                }
            }
            Console.WriteLine(aClassCounter[0]);
        }


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

namespace Guess_the_Tree
{
    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 = int.Parse(reader.ReadLine());

            string[] ss = reader.ReadLine().Split(' ');
           int[] nn = new int[n];
            for (int i = 0; i < n; i++)
            {
                nn[i] = int.Parse(ss[i]);
            }

            Array.Sort(nn);

            bool[] used = new bool[n];
bool ok = true;
            for (int i = 0; i < n; i++)
            {
                if (nn[i]>1)
                {
                    int count = nn[i] - 1;
                    int p = 0;
                    for (int j = i; j >=0; j--)
                    {
                        if (!used[j] && nn[j]<=count)
                        {
                            if (p == 0 && nn[j] == count)
                                continue;
                            used[j] = true;
                            count -= nn[j];
                            p++;
                        }
                        if (count==0)
                            break;
                    }
                    if (count!=0)
                    {
                        ok = false;
                        break;
                    }
                }
            }

            writer.WriteLine("{0}", ok ? "YES" : "NO");
            writer.Flush();
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
class Solver
{
    void Solve()
    {
        var n = sc.Integer();
        var m = sc.Integer();
        var hori = sc.ScanLine().Select(x => x == '>' ? 1 : -1).ToArray();
        var ver = sc.ScanLine().Select(x => x == 'v' ? 1 : -1).ToArray();
        var isGood = new bool[n, m];
        for (int r = 0; r < n; r++)
        {
            for (int c = 0; c < m; c++)
            {
                var good = false;
                var used = new bool[n, m];
                var qr = new Queue<int>();
                var qc = new Queue<int>();
                qr.Enqueue(r);
                qc.Enqueue(c);
                while (qr.Any())
                {
                    var pr = qr.Dequeue();
                    var pc = qc.Dequeue();
                    if (isGood[pr, pc])
                    {
                        good = true;
                        break;
                    }
                    used[pr, pc] = true;
                    //horizon
                    {
                        var nc = pc + hori[pr];
                        if (nc < 0 || nc >= m || used[pr, nc]) { }
                        else
                        {

                            qr.Enqueue(pr);
                            qc.Enqueue(nc);
                        }

                    }
                    //vertical
                    {
                        var nr = pr + ver[pc];
                        if (nr < 0 || nr >= n || used[nr, pc]) { }
                        else
                        {
                            qr.Enqueue(nr);
                            qc.Enqueue(pc);
                        }
                    }
                }
                if (good)
                {
                    isGood[r, c] = true;
                    continue;
                }
                for (int i = 0; i < n; i++)
                    for (int j = 0; j < m; j++)
                        if (!used[i, j])
                        {
                            Printer.PrintLine("NO");
                            return;
                        }
            }
        }
        Printer.PrintLine("YES");
    }

    static void Main()
    {
#if DEBUG
        var ostream = new System.IO.FileStream("debug.txt", System.IO.FileMode.Create, System.IO.FileAccess.Write);
        var iStream = new System.IO.FileStream("input.txt", System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite);
        Console.SetIn(new System.IO.StreamReader(iStream));
        System.Diagnostics.Debug.AutoFlush = true;
        System.Diagnostics.Debug.Listeners.Add(new System.Diagnostics.TextWriterTraceListener(new System.IO.StreamWriter(ostream, System.Text.Encoding.UTF8)));
        try
        {
#endif
            var solver = new Solver();
            solver.Solve();
#if DEBUG
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
            Console.WriteLine(ex.StackTrace);
        }
        Console.ReadKey(true);
#endif
    }
    _Scanner sc = new _Scanner();

}

static public class Printer
{
    static readonly private System.IO.TextWriter writer;
    static readonly private System.Globalization.CultureInfo info;
    static string Separator { get; set; }
    static Printer()
    {
        writer = Console.Out;
        info = System.Globalization.CultureInfo.InvariantCulture;
        Separator = " ";
    }

    static public void Print(int num) { writer.Write(num.ToString(info)); }
    static public void Print(int num, string format) { writer.Write(num.ToString(format, info)); }
    static public void Print(long num) { writer.Write(num.ToString(info)); }
    static public void Print(long num, string format) { writer.Write(num.ToString(format, info)); }
    static public void Print(double num) { writer.Write(num.ToString(info)); }
    static public void Print(double num, string format) { writer.Write(num.ToString(format, info)); }
    static public void Print(string str) { writer.Write(str); }
    static public void Print(string format, params object[] arg) { writer.Write(format, arg); }
    static public void Print(IEnumerable<char> sources) { writer.Write(sources.AsString()); }
    static public void Print(params object[] arg)
    {
        var res = new System.Text.StringBuilder();
        foreach (var x in arg)
        {
            res.AppendFormat(info, "{0}", x);
            if (!string.IsNullOrEmpty(Separator))
                res.Append(Separator);
        }
        writer.Write(res.ToString(0, res.Length - Separator.Length));
    }
    static public void Print<T>(IEnumerable<T> sources)
    {
        var res = new System.Text.StringBuilder();
        foreach (var x in sources)
        {
            res.AppendFormat(info, "{0}", x);
            if (string.IsNullOrEmpty(Separator))
                res.Append(Separator);
        }
        writer.Write(res.ToString(0, res.Length - Separator.Length));
    }
    static public void PrintLine(int num) { writer.WriteLine(num.ToString(info)); }
    static public void PrintLine(int num, string format) { writer.WriteLine(num.ToString(format, info)); }
    static public void PrintLine(long num) { writer.WriteLine(num.ToString(info)); }
    static public void PrintLine(long num, string format) { writer.WriteLine(num.ToString(format, info)); }
    static public void PrintLine(double num) { writer.WriteLine(num.ToString(info)); }
    static public void PrintLine(double num, string format) { writer.WriteLine(num.ToString(format, info)); }
    static public void PrintLine(string str) { writer.WriteLine(str); }
    static public void PrintLine(string format, params object[] arg) { writer.WriteLine(format, arg); }
    static public void PrintLine(IEnumerable<char> sources) { writer.WriteLine(sources.AsString()); }
    static public void PrintLine(params object[] arg)
    {
        var res = new System.Text.StringBuilder();
        foreach (var x in arg)
        {
            res.AppendFormat(info, "{0}", x);
            if (!string.IsNullOrEmpty(Separator))
                res.Append(Separator);
        }
        writer.WriteLine(res.ToString(0, res.Length - Separator.Length));
    }
    static public void PrintLine<T>(IEnumerable<T> sources)
    {
        var res = new System.Text.StringBuilder();
        foreach (var x in sources)
        {
            res.AppendFormat(info, "{0}", x);
            if (!string.IsNullOrEmpty(Separator))
                res.Append(Separator);
        }
        writer.WriteLine(res.ToString(0, res.Length - Separator.Length));
    }
    static public void PrintLine(System.Linq.Expressions.Expression<Func<string, object>> ex)
    {
        var res = ex.Parameters[0];
        writer.WriteLine(res.Name);
    }
}
public class _Scanner
{
    readonly private System.Globalization.CultureInfo info;
    readonly System.IO.TextReader reader;
    string[] buffer = new string[0];
    int position;

    public char[] Separator { get; set; }
    public _Scanner(System.IO.TextReader reader = null, string separator = null, System.Globalization.CultureInfo info = null)
    {

        this.reader = reader ?? Console.In;
        if (string.IsNullOrEmpty(separator))
            separator = " ";
        this.Separator = separator.ToCharArray();
        this.info = info ?? System.Globalization.CultureInfo.InvariantCulture;
    }
    public string Scan()
    {
        if (this.position < this.buffer.Length)
            return this.buffer[this.position++];
        this.buffer = this.reader.ReadLine().Split(this.Separator, StringSplitOptions.RemoveEmptyEntries);
        this.position = 0;
        return this.buffer[this.position++];
    }

    public string[] ScanToEndLine()
    {
        if (this.position >= this.buffer.Length)
            return this.reader.ReadLine().Split(this.Separator, StringSplitOptions.RemoveEmptyEntries);
        var size = this.buffer.Length - this.position;
        var ar = new string[size];
        Array.Copy(this.buffer, position, ar, 0, size);
        return ar;

    }

    public string ScanLine()
    {
        if (this.position >= this.buffer.Length)
            return this.reader.ReadLine();
        else
        {
            var sb = new System.Text.StringBuilder();
            for (; this.position < buffer.Length; this.position++)
            {
                sb.Append(this.buffer[this.position]);
                sb.Append(' ');
            }
            return sb.ToString();
        }
    }
    public string[] ScanArray(int length)
    {
        var ar = new string[length];
        for (int i = 0; i < length; i++)
        {
            ar[i] = this.Scan();
        }
        return ar;
    }

    public int Integer()
    {
        return int.Parse(this.Scan(), info);
    }
    public long Long()
    {
        return long.Parse(this.Scan(), info);
    }
    public double Double()
    {
        return double.Parse(this.Scan(), info);
    }
    public double Double(string str)
    {
        return double.Parse(str, info);
    }

    public int[] IntArray(int length)
    {
        var a = new int[length];
        for (int i = 0; i < length; i++)
            a[i] = this.Integer();
        return a;
    }
    public long[] LongArray(int length)
    {
        var a = new long[length];
        for (int i = 0; i < length; i++)
            a[i] = this.Long();
        return a;
    }
    public double[] DoubleArray(int length)
    {
        var a = new double[length];
        for (int i = 0; i < length; i++)
            a[i] = this.Double();
        return a;
    }

}
static public partial class EnumerableEx
{
    static public string AsString(this IEnumerable<char> source)
    {
        return new string(source.ToArray());
    }
    static public IEnumerable<T> Enumerate<T>(this int count, Func<int, T> selector)
    {
        return Enumerable.Range(0, count).Select(x => selector(x));
    }
}


using System;
using System.Linq;
namespace codeforces
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] nk = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            int nowPage = nk[1];
            int rez = 1;
            int i = 1;
            while (nowPage<nk[0])
            {
                nowPage += -nk[4] + nk[1]+nk[3] * i++;
                rez++;
            }
            Console.WriteLine(rez);
        }
    }
}


using System;

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

            int c = int.Parse(tokens[0]);
            int v0 = int.Parse(tokens[1]);
            int v1 = int.Parse(tokens[2]);
            int a = int.Parse(tokens[3]);
            int l = int.Parse(tokens[4]);

            for (int day = 1, v = v0, read = v; ; day++, read = Math.Max(0, read - l) + v, v = Math.Min(v + a, v1))
            {
                if (read >= c)
                {
                    Console.WriteLine(day);
                    break;
                }
            }
        }
    }
}


using System;
using System.Linq;

namespace Contest
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] str1 = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int[] a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            int n = str1[0];
            int m = str1[1] - 1;
            int k = str1[2];

            int distance1 = 0;
            for (int i = m + 1; i <= n; ++i)
            {
                if (a[i] != 0 && a[i] <= k)
                {
                    distance1 = (i - m) * 10;
                    break;
                }
            }

            int distance2 = 0;
            for (int i = m - 1; i >= 0; --i)
            {
                if (a[i] != 0 && a[i] <= k)
                {
                    distance2 = (m - i) * 10;
                    break;
                }
            }

            int result;
            if (distance1 == 0)
            {
                result = distance2;
            }
            else if (distance2 == 0)
            {
                result = distance1;
            }
            else
            {
                result = Math.Min(distance1, distance2);
            }

            Console.WriteLine(result);
            ///////////////////////////////
            //Console.ReadKey();
        }
    }
}


using System;

namespace BuyAShovel
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split();

            int price = Convert.ToInt32(input[0]);
            int change = Convert.ToInt32(input[1]);

            bool paid = false;

            int curentPrice = price;
            int items = 1;

            while (paid == false)
            {
                if (curentPrice % 10 != 0 || (curentPrice - change) % 10 != 0)
                {
                    items++;
                    curentPrice += price;
                }
                else
                {
                    paid = true;
                }
            }

            Console.WriteLine(items);
        }
    }
}


using System;
using System.Collections.Generic;
namespace shoval
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int sum = 1, TotalPrice = 0;
            int Price = int.Parse(input[0];
            r = int.Parse(input[1]);
            TotalPrice = x ;
               while (true)
            {
                if ((x*sum) % 10 ==0 || (sum*x) % 10 == Price)
                    break;
                TotalPrice +=x;
                sum++;
            }
            Console.WriteLine(sum);
        }
    }
}


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

public class Program
{
	public static void Main()
	{
		var arr= Console.ReadLine().Split();
        int n=int.Parse(arr[0]);
		int r=int.Parse(arr[1]);
		int p=0;

		for(int i=1; i<int.MaxValue; i++)
		{
			int s=n*i;
			if(s%10!=r)
			{
				p++;
			}
			else if(s%10==r)
			{
				p++;
				break;
			}
		}
		Console.WriteLine(p);
	}
}


using System;

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

            int[] coins = GetInts();
            Console.WriteLine(SolveProblem(coins));
            Console.ReadLine();
        }

        static int  SolveProblem (int [] coins)
        {
            int total = 0;
            int min = 0;
            do
            {
                total += coins[0];
                min++;
            } while ((total - coins [1]) % 10 != 0);
            return min;

        }

        static int[] GetInts()
        {
            string[] s = (Console.ReadLine()).Split(' ');
            int[] integers = new int[s.Length];
            for (int i = 0; i < s.Length; i++)
            {
                integers[i] = int.Parse(s[i]);
            }
            return integers;
        }

    }
}


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

namespace CodeForces
{
    class Program
    {
        static void Main(string[] args)
        {
            var Input = Convert.ToString(Console.ReadLine());
            var MasInp = Input.Split(' ');

            int k = Convert.ToInt32(MasInp[0]);
            int j = Convert.ToInt32(MasInp[1]);
            int sum = k;

            while()
            {
                int Res = sum
                sum += k;
            }

            Console.Write(sum / k);
        }
    }
}


using System;

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

            string s = Console.ReadLine();
            Console.WriteLine(Fun(s));

        }

        static public string Fun(string s)
        {
            int a, b;
            string da = "Dasha"; int d = 0;
            string ma = "Masha"; int m = 0;
            string eq = "Equal"; int e = 0;
            string[] arr = s.Split(' ');
            a = Convert.ToInt32(arr[0]);
            b = Convert.ToInt32(arr[1]);
            int per = nok(a, b);
            if (a < b) return ma ;
            else if (b < a) return da;

        }
        static public int nok(int a, int b)
        {
            return (a / nod(a, b)) * b;
        }
        static public int nod(int a, int b)
        {
            if (a != 0) return nod(b % a, a);
            else return b;
        }
    }
}


using System;
using System.Collections.Generic;
namespace helloapp
{
    class Program
    {

        static void Main(string[] args)
        {
            int num = int.Parse(Console.ReadLine());
            int[] lucky = new int[100];
            int count = 0;
            for(int i=0; i<=num;i++){
                string str = i.ToString();
                bool flag = false;
                for(int j=0; j<str.Length; j++){
                    if(str[j]!='4' && str[j]!='7')
                        flag=true;
                }
                if(!flag)
                    lucky[count++]=i;

            }
            for(int i = 0; i<lucky.Length; i++)
                        if(num==lucky[i] || num%lucky[i]==0)
                        Console.WriteLine("Yes");
        }
    }
}


/*
 * 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.Linq;
using System.IO;
using System.Text;
using System.Collections.Generic;

namespace ProgrammingCompetitions
{
	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
		static Queue<string> testInput = new Queue<string>(string.Format(@"

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

		static string str(double a)
		{
			return a.ToString("0.0000000000", System.Globalization.CultureInfo.InvariantCulture);
		}

		static long calc(long val)
		{
			if (val * k >= d)
				return long.MaxValue;

			long res = val * ((a * k) + t);
			long rem = d - val * k;
			long last = Math.Min(k, rem);
			res += last * a;
			rem -= last;
			res += rem * b;
			return res;
		}

		static long d, k, a, b, t;
		static string Solve()
		{
			checked
			{
				read(out d, out k, out a, out b, out t);

				long left = 0;
				long right = d / k + 1;

				while (left < right)
				{
					long mid = (left + right) >> 1;
					if (calc(mid) < calc(mid + 1))
					{
						right = mid;
					}
					else
					{
						left = mid + 1;
					}
				}

				return calc(left).ToString();
			}
		}
#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>()
		{
			return readMany<T>(' ');
		}

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

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

		private static T[][] readMany<T>(int n)
		{
			T[][] 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)
		{
			T[][] res = new T[height][];
			for (int _ = 0; _ < height; _++)
			{
				res[_] = read().Select(c => map(c)).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)
		{
			var vals = readMany();
			t1 = (T1)Convert.ChangeType(vals[0], typeof(T1));
		}

		private static void read<T1, T2>(out T1 t1, out T2 t2)
		{
			var 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)
		{
			var 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)
		{
			var 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)
		{
			var 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));
		}

		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) =>
			{
				var key = Tuple.Create(t1);
				if (!cache.ContainsKey(key))
					cache.Add(key, f(t1, res));
				return cache[key];
			};
			return res;
		}

		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) =>
			{
				var key = Tuple.Create(t1, t2);
				if (!cache.ContainsKey(key))
					cache.Add(key, f(t1, t2, res));
				return cache[key];
			};
			return res;
		}

		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) =>
			{
				var key = Tuple.Create(t1, t2, t3);
				if (!cache.ContainsKey(key))
					cache.Add(key, f(t1, t2, t3, res));
				return cache[key];
			};
			return res;
		}

		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) =>
			{
				var 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;
		}

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

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

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

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

		public static T[][] mkarr<T>(int x, int y)
		{
			T[][] 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)
		{
			T[][][] 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;
		}

		static bool[] tf = new[] { 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
		static void Main(string[] args)
		{
#if DEBUG
			var sw = new System.Diagnostics.Stopwatch();
			sw.Start();
#endif
			string s = Solve();
			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 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<IEnumerable<T>> res = source.First().Select(x => single(x));
			foreach (IEnumerable<T> next in source.Skip(1))
			{
				res = res.Cartesian(next, (sofar, n) => sofar.Concat(single(n)));
			}
			return res;
		}

		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 (var pair in inp)
			{
				if (pair.Item2)
				{
					yield return pair.Item1;
				}
			}
		}

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

		public static IEnumerable<IEnumerable<T>> Combinations<T>(this IEnumerable<T> it)
		{
			foreach (var conf in new[] { true, false }.Pow(it.Count()))
			{
				yield return it.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)
		{
			if (it.Count() < 2)
			{
				yield return it;
				yield break;
			}

			foreach (T first in it)
			{
				foreach (IEnumerable<T> part in Permutations(it.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;

			while (true)
			{
				foreach (T item in source)
				{
					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;
			while (true)
			{
				foreach (T item in source)
				{
					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;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

//namespace Practice
//{
    class TaskF
    {
        public static void Main(string[] args)
        {
            new TaskF().solve();
        }
        const int P = 1000000007;
        public int pow(int a, int b)
        {
            if (b == 0) return 1;
            int res = pow(a, (b >> 1));
            res = (int)((1L * res * res) % P);
            if ((b & 1) == 1)
            {
                return (int)((1L * res * a) % P);
            }
            return res;
        }

        int comb(int n, int k, int[] fac, int[] finv)
        {
            if (k > n) return 0;
            if (k == 0 || k == n) return 1;
            return (int) ((((1L * fac[n] * finv[k]) % P) * finv[n-k]) % P);
        }

        public void solve()
        {
            string[] inputs = Console.ReadLine().Split(' ');
            int f = int.Parse(inputs[0]);
            int w = int.Parse(inputs[1]);
            int h = int.Parse(inputs[2]);

            if (w == 0 || h == 0)
            {
                Console.WriteLine(1);
                return;
            }
            else if (f == 0)
            {
                if (w > h)
                {
                    Console.WriteLine(1);
                    return;
                }
                else
                {
                    Console.WriteLine(0);
                    return;
                }
            }
            if (w <= h && w > 0)
            {
                Console.WriteLine(0);
                return;
            }
            int n = Math.Max(f + 1, w - 1) + 1;
            int[] fac = new int[n];
            int[] finv = new int[n];
            fac[0] = finv[0] = 1;
            fac[1] = finv[1] = 1;
            for (int i = 2; i < n; i++)
            {
                fac[i] = (int)((1L * fac[i - 1] * i) % P);
                finv[i] = pow(fac[i], P - 2);
            }

            int all = 0, good = 0, f1 = f + 1, w1 = w - 1, upper = w / (h + 1);
            for (int u = 1; u <= w; u++)
            {
                if (u > f1) break;
                int f1u = comb(f1, u, fac, finv);
                all += mult(f1u, comb(w1, u - 1, fac, finv));
                all %= P;
                if (u <= upper)
                {
                    good += mult(f1u, comb(w - u * h - 1, u - 1, fac, finv));
                }
            }
            //Console.WriteLine(pow(all, P-2));
            int res = (int)(1L * good * pow(all, P - 2) % P);
            //Console.WriteLine(res + " = " + good +" / " + all);
            Console.WriteLine(res);

            //Console.Read();
        }
        public int mult(int a, int b)
        {
            return (int)((1L * a * b) % P);
        }
    }
//}


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

namespace Practice
{
    class TaskF
    {
        //public static void Main(string[] args)
        //{
        //    new TaskF().solve();
        //}
        const int P = 1000000007;
        public int pow(int a, int b)
        {
            if (b == 0) return 1;
            int res = pow(a, (b >> 1));
            res = (int)(1L * res * res % P);
            if ((b & 1) == 1)
            {
                return (int)(1L * res * a % P);
            }
            return res;
        }

        int comb(int n, int k, int[] fac, int[] finv)
        {
            if (k == 0 || k == n) return 1;
            return (int) (((1L * fac[n] * finv[k] % P) * finv[n-k]) % P);
        }

        public void solve()
        {
            string[] inputs = Console.ReadLine().Split(' ');
            int f = int.Parse(inputs[0]);
            int w = int.Parse(inputs[1]);
            int h = int.Parse(inputs[2]);

            if (w == 0 || h == 0)
            {
                Console.WriteLine(1);
                return;
            }
            else if (f == 0)
            {
                if (w > h)
                {
                    Console.WriteLine(1);
                    return;
                }
                else
                {
                    Console.WriteLine(0);
                    return;
                }
            }
            if (w <= h && w > 0)
            {
                Console.WriteLine(0);
                return;
            }
            int n = Math.Max(f + 1, w - 1) + 1;
            int[] fac = new int[n];
            int[] finv = new int[n];
            fac[0] = finv[0] = 1;
            fac[1] = finv[1] = 1;
            for (int i = 2; i < n; i++)
            {
                fac[i] = (int)(1L * fac[i - 1] * i % P);
                finv[i] = pow(fac[i], P - 2);
            }

            int all = 0, good = 0, f1 = f + 1, w1 = w - 1, upper = w / (h + 1);
            for (int u = 1; u <= w; u++)
            {
                if (u > f1) break;
                int f1u = comb(f1, u, fac, finv);
                all += mult(f1u, comb(w1, u - 1, fac, finv));
                all %= P;
                if (u <= upper)
                {
                    good += mult(f1u, comb(w - u * h - 1, u - 1, fac, finv));
                }
            }
            Console.WriteLine(pow(all, P-2));
            int res = (int)(1L * good * pow(all, P - 2) % P);
            //Console.WriteLine(res + " = " + good +" / " + all);
            Console.WriteLine(res);

            //Console.Read();
        }
        public int mult(int a, int b)
        {
            return (int)(1L * a * b % P);
        }
    }
}


<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{0D76C9E7-FD9E-4713-B82F-27910CE473BD}</ProjectGuid>
    <OutputType>Exe</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>ConsoleApplication9</RootNamespace>
    <AssemblyName>ConsoleApplication9</AssemblyName>
    <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="System" />
    <Reference Include="System.Core" />
    <Reference Include="System.Xml.Linq" />
    <Reference Include="System.Data.DataSetExtensions" />
    <Reference Include="Microsoft.CSharp" />
    <Reference Include="System.Data" />
    <Reference Include="System.Xml" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="Program.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
  </ItemGroup>
  <ItemGroup>
    <None Include="App.config" />
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  </Target>
  <Target Name="AfterBuild">
  </Target>
  -->
</Project>