Imports System
Public Class Program
Public Shared Function CountCharactersNeedToBeRemovedForAnagram(ByVal str1 As String, ByVal str2 As String) As Integer
Dim TotalABCLetters As Integer = 26
Dim count1 As Integer() = New Integer(TotalABCLetters - 1) {}
Dim count2 As Integer() = New Integer(TotalABCLetters - 1) {}
Dim size1 As Integer = str1.Length
Dim size2 As Integer = str2.Length
For i As Integer = 0 To size1 - 1
count1(Convert.ToInt32(str1(i)) - 97) += 1 ' "a"c = 97 ASCII
Next
For i As Integer = 0 To size2 - 1
count2(Convert.ToInt32(str2(i)) - Convert.ToByte("a"c)) += 1
Next
Dim result As Integer = 0
For i As Integer = 0 To TotalABCLetters - 1
result += Math.Abs(count1(i) - count2(i))
Next
Return result
End Function
Public Shared Sub Main(ByVal args As String())
Dim str1 As String = "masterfx"
Dim str2 As String = "ksampret"
Console.Write(CountCharactersNeedToBeRemovedForAnagram(str1, str2))
End Sub
End Class
' run:
'
' 4
'