import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

void main() {
    const N = readln.chomp.to!long;
    auto S = readln.chomp.map!(c => c.to!long).array;
    N.iota.map!(i => S[0..i].sort!((a,b) => a < b).uniq.filter!(c => S[i..$].canFind(c)).count).reduce!max.writeln;
}

