using System;
public class Program
{
public static void Main()
int n = Convert.ToInt32(Console.ReadLine());
int k = Convert.ToInt32(Console.ReadLine());
int x = n;
int y = n;
int count = 0;
while (y > 0)
x = y % 10;
y /= 10;
if (x == k)
count++;
}
Console.WriteLine(count);