#include<stdio.h>
#include<iostream>
#include<string.h>
#include<string>
#include<ctype.h>
#include<math.h>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<bitset>
#include<algorithm>
#include<time.h>
using namespace std;
void fre(){freopen("c://test//input.in","r",stdin);freopen("c://test//output.out","w",stdout);}
#define MS(x,y) memset(x,y,sizeof(x))
#define MC(x,y) memcpy(x,y,sizeof(x))
#define MP(x,y) make_pair(x,y)
#define ls o<<1
#define rs o<<1|1
typedef long long LL;
typedef unsigned long long UL;
typedef unsigned int UI;
template <class T1,class T2>inline void gmax(T1 &a,T2 b){if(b>a)a=b;}
template <class T1,class T2>inline void gmin(T1 &a,T2 b){if(b<a)a=b;}
const int N=0,M=0,Z=1e9+7,ms63=0x3f3f3f3f;
int n,m,x;
int a[12];
LL C(LL x)
{
return x*(x-1)/2;
}
int main()
{
while(~scanf("%d%d",&n,&m))
{
MS(a,0);
for(int i=1;i<=n;++i)
{
scanf("%d",&x);
++a[x];
}
LL ans=C(n);
for(int i=1;i<=m;++i)ans-=C(a[i]);
printf("%lld\n",ans);
}
return 0;
}
/*
【trick&&吐槽】
注意不要爆int
【题意】
有n(2<=n<=2e5)本书,书有共计m(2<=m<=10)个类型。依次告诉你每本书的类型。
我们想选出两本书,要求这两本书不能类型相同,问你有多少种选法。
【类型】
水题 简单容斥
【分析】
显然 C(tot,2)- ∑(i=1~m)C(typei,2)就是答案了。
【时间复杂度&&优化】
O(n)
*/