#include "bits//stdc++.h"
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

#define rep(i,n) for (int i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
int a[100000];
vector<int> G[100000];
int in[100000];
int N, K;
int ans;
int solve(int v) {
	if (G[v].size() == 0) return 0;
	int ma = 0;
	for (int to : G[v]) {
		int t = solve(to) + 1;
		if (t == K && v > 0) {
			t = 0;
			ans++;
		}
		ma = max(ma, t);
	}
	return ma;

}
int main() {
	cin >> N >> K;
	rep(i, N) {
		cin >> a[i];
		a[i]--;
	}
	if (a[0] != 0) ans++;
	for (int i = 1; i < N; i++) {
		G[a[i]].push_back(i);
	}
	solve(0);
	cout << ans << endl;
}

#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

const int x_max = 100004;
const int n_max = 205;

signed main(){
    int n,x;
    cin >> n >> x;
    int A[n];
    REP(i,n) cin >> A[i];
    sort(A,A+n);

    int dp[2][x_max];
    REP(j,x_max) dp[0][j] = j % A[0];
    FOR(i,1,n){
        REP(j,x_max){
            dp[i%2][j] = 0;
            Add(dp[i%2][j],dp[(i-1)%2][j % A[i]]);
            Add(dp[i%2][j],i * dp[(i-1)%2][j]);
        }
    }
    cout << dp[(n-1)%2][x] << endl;

}