http://acm.zjgsu.edu.cn/JudgeOnline/showproblem?problem_id=1260
/**/ /*
动态规划 dp[i][j]表示从1到i中递增序列长度为j且最后一个数为num[i]的序列个数
*/

#include
< iostream >
using   namespace  std;
__int64 dp[
101 ][ 101 ];
int  main()
{
    
int n,k;
    
while(cin>>n>>&& n+k)
    
{
        
int i,j,t,num[101];
        
for(i=1;i<=n;i++)
            cin
>>num[i];
        
for(i=0;i<=n;i++)
            
for(j=0;j<=n;j++)
                dp[i][j]
=0;
        
for(i=1;i<=n;i++)
            dp[i][
1]=1;
        
for(j=2;j<=k;j++)
            dp[
1][j]=0;
        
for(i=2;i<=n;i++)
        
{
            
for(j=2;j<=k;j++)
            
{
                
for(t=1;t<i;t++)
                
{
                    
if(num[i]>num[t])
                        dp[i][j]
+=dp[t][j-1];
                }

            }

        }

        __int64 sum
=0;
        
for(i=k;i<=n;i++)
            sum
+=dp[i][k];
        printf(
"%I64d\n",sum);
    }

    
return 0;
}