Problem:
Score : 100 points

Problem Statement

You will be given a string S of length 3 representing the weather forecast for three days in the past.

The i-th character (1 \leq i \leq 3) of S represents the forecast for the i-th day. S, C, and R stand for sunny, cloudy, and rainy, respectively.

You will also be given a string T of length 3 representing the actual weather on those three days.

The i-th character (1 \leq i \leq 3) of S represents the actual weather on the i-th day. S, C, and R stand for sunny, cloudy, and rainy, respectively.

Print the number of days for which the forecast was correct.

Constraints

S and T are strings of length 3 each.

S and T consist of S, C, and R.

Input

Input is given from Standard Input in the following format:

S
T

Output

Print the number of days for which the forecast was correct.

Sample Input 1

CSS
CSR

Sample Output 1

2

For the first day, it was forecast to be cloudy, and it was indeed cloudy.

For the second day, it was forecast to be sunny, and it was indeed sunny.

For the third day, it was forecast to be sunny, but it was rainy.

Thus, the forecast was correct for two days in this case.

Sample Input 2

SSR
SSR

Sample Output 2

3

Sample Input 3

RRR
SSS

Sample Output 3

0

Solution in Julia (0.5.0) (judge verdict: Runtime Error)

const PAIR = Pair{Int,Int}

#################### library ####################


#################### graph ####################

const Graph = Dict{Int,Vector{Int}}
const GraphPAIR = Dict{PAIR,Vector{PAIR}}

# graph: { node: [node] }
function is_cyclic(graph::GraphPAIR)
	for pair in graph
		x0 = pair.first
		v = [x0]	# stack
		s::Set{Pair} = Set{Pair}()
		while !isempty(v)
			x = pop!(v)
			for y in graph[x]
				if !in(y, s)
					push!(s, y)
					push!(v, y)
				end
			end
		end
		
		if in(x0, s)
			return true
		end
	end
	
	return false
end


#################### naive ####################


#################### process ####################

function read_input()
	N = parse(Int, readline())
	table = [ [ parse(Int, s) for s in split(readline()) ] for _ in 1:N ]
	return table
end

function make_graph(table)::GraphPAIR
	function f(v)
		dic::Dict{Int,Int} = Dict()
		k = 0
		for e in v
			dic[e] = k
		end
		return dic
	end
	
	N = length(table)
	dics = [ f(v) for v in table ]
	graph::GraphPAIR = Dict()
	for i in 1:N-1
		for j in i+1:N
			graph[PAIR(i,j)] = []
		end
	end
	for pair in graph
		k = pair.first.first
		l = pair.first.second
		i1 = dics[k][l]
		if i1 < N-1
			j1 = table[k][i1+1]
			push!(graph[Pair(k, l)], minimum([Pair(k, j1), Pair(j1, k)]))
		end
		i2 = dics[l][k]
		if i2 < N-1
			j2 = table[l][i2+1]
			push!(graph[Pair(k, l)], minimum([Pair(l, j2), Pair(j2, l)]))
		end
	end
	return graph
end

function f()
	table = read_input()
	N = length(table)
	memo::Dict{PAIR,Int} = Dict()
	graph::GraphPAIR = make_graph(table)
	if is_cyclic(graph)
		return -1
	end
	
	unvisited = Set(Pair(n, m) for n in 1:N-1 for m in n+1:N)
	for pair in graph
		if length(pair.second) == 0
			memo[pair.first] = 1
			pop!(unvisited, pair.first)
		end
	end
	
	for i in 1:N-1
		for j in i+1:N
			v = Pair(i, j)
			if !in(v, unvisited)
				continue
			end
			stack = [v]
			while !isempty(stack)
				v = pop!(stack)
				unvs = [ v1 for v1 in graph[v] if in(v1, unvisited) ]
				if isempty(unvs)
					dist = maximum([memo[v1]+1 for v1 in graph[v]])
					memo[v] = dist
					pop!(unvisited, v)
				else
					push!(stack, v)
					for v1 in unvs
						push!(stack, v1)
					end
				end
			end
		end
	end
	
	return maximum(pair.second for pair in memo)
end


#################### main ####################

println(f())