import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

const long MOD = 998244353;
const int INF = 1 << 29;

void main() {
    auto N = readln.chomp.to!int;
    auto S = N.iota.map!(_ => readln.chomp).array;

    auto dp = new int[](26);
    fill(dp, INF);
    dp[S.front.front - 'a'] = 1;

    foreach (i; 1..N) {
        dp[S[i].front - 'a'] = min(dp[S[i].front - 'a'],
                                   dp[S[i-1].front - 'a'] + 1);
    }

    dp[S.back.front - 'a'].writeln;
}

