def stringCost(s):
    lastEntry = [-1] * 26
    cost = 0
    for i, c in enumerate(s):
        if lastEntry[ord(c) - ord('a')] == -1:
            cost += 1
            lastEntry[ord(c) - ord('a')] = i
    return cost


s1 = 'abcd'
print(stringCost(s1))
s2 = 'abab'
print(stringCost(s2))

266172758537e153d7228f0175a682ad6f13af1e
<mask token>

def stringCost(s):
    lastEntry = [-1] * 26
    cost = 0
    for i, c in enumerate(s):
        if lastEntry[ord(c) - ord('a')] == -1:
            cost += 1
            lastEntry[ord(c) - ord('a')] = i
    return cost


<mask token>

def stringCost(s):
    lastEntry = [-1] * 26
    cost = 0
    for i, c in enumerate(s):
        if lastEntry[ord(c) - ord('a')] == -1:
            cost += 1
            lastEntry[ord(c) - ord('a')] = i
    return cost


<mask token>
print(stringCost(s1))
<mask token>
print(stringCost(s2))

def stringCost(s):
    lastEntry = [-1] * 26
    cost = 0
    for i, c in enumerate(s):
        if lastEntry[ord(c) - ord('a')] == -1:
            cost += 1
            lastEntry[ord(c) - ord('a')] = i
    return cost


s1 = 'abcd'
print(stringCost(s1))
s2 = 'abab'
print(stringCost(s2))
