unittest
{
	assert( [ "4", "0224" ].parse.expand.solve == 3 );
	assert( [ "6", "123123" ].parse.expand.solve == 17 );
	assert( [ "19", "3141592653589793238" ].parse.expand.solve == 329 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	input.popFront;
	auto s = input.front.map!( ( a ) => cast( long )( a - '0' ) ).array;
	return tuple( n, s );
}

auto solve( long n, long[] s )
{
	bool[ string ] ks;
	auto as = new bool[ 10 ];
	foreach( i, a; s )
	{
		if( as[ a ] ) continue;
		as[ a ] = true;
		
		auto bs = new bool[ 10 ];
		foreach( j, b; s[ i + 1 .. $ ] )
		{
			if( bs[ b ] ) continue;
			bs[ b ] = true;
			
			auto cs = new bool[ 10 ];
			foreach( c; s[ i + 1 + j + 1 .. $ ] )
			{
				if( cs[ c ] ) continue;
				cs[ c ] = true;
				
				ks[ [ a, b, c ].to!( string ) ] = true;
			}
		}
	}
	return ks.length;
}
