// ...
#pragma GCC optimize("Ofast", "unroll-loops")
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(a) (ll)((a).size())
#define heap priority_queue
#define hash_map unordered_map
#define hash_set unordered_set
#define ft first
#define sd second
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define mineq(a, b) (a) = min((a), (b))
#define maxeq(a, b) (a) = max((a), (b))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef vector<ll> vll;
typedef set<ll> sll;
typedef map<ll, ll> mll;
const ll inf = numeric_limits<ll>::max() / 2;
const ld eps = 1e-9;
const ld pi = acos(-1);

const ll R = 1e9 + 7;
const ll K = 5;

ll n, x;
vll d, dist, dp;
vector<vll> matrix(K + 2, vll(K + 2, 0));
vector<vll> beg(K + 2, vll(1, 0));

void gen() {
	for (ll i = 0; i <= K; i++) {
		matrix[i][i + 1] = 1;
	}
	for (ll i : d) {
		++matrix[K + 1][K + 2 - i];
	}
}

void genbeg() {
	beg[0][0] = 1;
	for (ll i = 0; i <= K + 1; i++) {
		for (ll j : d) {
			if (i - j >= 0) {
				beg[i][0] += beg[i - j][0];
				beg[i][0] %= R;
			}
		}
	}
	for (ll i = 1; i <= K + 1; i++) {
		beg[i][0] += beg[i - 1][0];
		beg[i][0] %= R;
	}
}

vector<vll> mult(vector<vll> &a, vector<vll> &b) {
	ll n = sz(a), m = sz(b[0]), l = sz(b);
	vector<vll> c(n, vll(m, 0));
	for (ll i = 0; i < n; i++) {
		for (ll j = 0; j < m; j++) {
			for (ll k = 0; k < l; k++) {
				c[i][j] += a[i][k] * b[k][j] % R;
				c[i][j] %= R;
			}
		}
	}
	return c;
}

vector<vll> binpow(vector<vll> &a, ll n) {
	if (n == 0) {
		vector<vll> unit(sz(a), vll(sz(a), 0));
		for (ll i = 0; i < sz(a); i++) {
			unit[i][i] = 1;
		}
		return unit;
	}
	if (n == 1) {
		return a;
	}
	vector<vll> ans = binpow(a, n / 2);
	ans = mult(ans, ans);
	if (n % 2 == 1) {
		ans = mult(ans, a);
	}
	return ans;
}

inline void solve() {
	gen();
	genbeg();
	vector<vll> a = binpow(matrix, x);
	a = mult(a, beg);
	ll ans = a[0][0];
	cout << ans << endl;
}

inline void read() {
	cin >> n >> x;
	d.resize(n);
	for (ll i = 0; i < n; i++) {
		cin >> d[i];
	}
}

int main() {
	fast;
	read();
	solve();
	return 0;
}


// ...
#pragma GCC optimize("Ofast", "unroll-loops")
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(a) (ll)((a).size())
#define heap priority_queue
#define hash_map unordered_map
#define hash_set unordered_set
#define ft first
#define sd second
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define mineq(a, b) (a) = min((a), (b))
#define maxeq(a, b) (a) = max((a), (b))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef vector<ll> vll;
typedef set<ll> sll;
typedef map<ll, ll> mll;
const ll inf = numeric_limits<ll>::max() / 2;
const ld eps = 1e-9;
const ld pi = acos(-1);

ll n, x;
vll d, dist, dp;

inline void solve() {
	dist.assign(x + 1, 0);
	dist[0] = 1;
	for (ll i = 0; i <= x; i++) {
		for (ll j : d) {
			if (i - j >= 0) {
				dist[i] += dist[i - j];
			}
		}
	}
	dp = dist;
	for (ll i = 1; i <= x; i++) {
		dp[i] += dp[i - 1];
	}
	cout << dp[x] << endl;
}

inline void read() {
	cin >> n >> x;
	d.resize(n);
	for (ll i = 0; i < n; i++) {
		cin >> d[i];
	}
}

int main() {
	fast;
	read();
	solve();
	return 0;
}


// ...
#pragma GCC optimize("Ofast", "unroll-loops")
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(a) (ll)((a).size())
#define heap priority_queue
#define hash_map unordered_map
#define hash_set unordered_set
#define ft first
#define sd second
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define mineq(a, b) (a) = min((a), (b))
#define maxeq(a, b) (a) = max((a), (b))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef vector<ll> vll;
typedef set<ll> sll;
typedef map<ll, ll> mll;
const ll inf = numeric_limits<ll>::max() / 2;
const ld eps = 1e-9;
const ld pi = acos(-1);

const ll R = 1e9 + 7;
const ll K = 100;

ll n, x;
vll d;
vector<vll> matrix(K + 3, vll(K + 3, 0));
vector<vll> beg(K + 3, vll(1, 0));

void gen() {
	for (ll i = 0; i <= K; i++) {
		matrix[i][i + 1] = 1;
	}
	for (ll i : d) {
		++matrix[K + 1][K + 1 - i + 1];
	}
	++matrix[K + 2][0];
	++matrix[K + 2][K + 2];
}

void genbeg() {
	beg[0][0] = 1;
	for (ll i = 1; i <= K + 1; i++) {
		for (ll j : d) {
			if (i - j >= 0) {
				beg[i][0] += beg[i - j][0];
				beg[i][0] %= R;
			}
		}
	}
}

vector<vll> mult(vector<vll> &a, vector<vll> &b) {
	ll n = sz(a), m = sz(b[0]), l = sz(b);
	vector<vll> c(n, vll(m, 0));
	for (ll i = 0; i < n; i++) {
		for (ll j = 0; j < m; j++) {
			for (ll k = 0; k < l; k++) {
				c[i][j] += a[i][k] * b[k][j] % R;
				c[i][j] %= R;
			}
		}
	}
	return c;
}

vector<vll> binpow(vector<vll> &a, ll n) {
	if (n == 0) {
		vector<vll> unit(sz(a), vll(sz(a), 0));
		for (ll i = 0; i < sz(a); i++) {
			unit[i][i] = 1;
		}
		return unit;
	}
	if (n == 1) {
		return a;
	}
	vector<vll> ans = binpow(a, n / 2);
	ans = mult(ans, ans);
	if (n % 2 == 1) {
		ans = mult(ans, a);
	}
	return ans;
}

inline void solve() {
	for (ll i = 0; i < sz(matrix); i++) {
		for (ll j = 0; j < sz(matrix); j++) {
			matrix[i][j] = 0;
		}
	}
	for (ll i = 0; i < sz(beg); i++) {
		beg[i][0] = 0;
	}
	gen();
	genbeg();
	vector<vll> a = binpow(matrix, x);
	a = mult(a, beg);
	ll ans = (a[0][0] + a.back()[0]) % R;
	cout << ans << endl;
}

inline void read() {
	cin >> n >> x;
	d.assign(n, 0);
	for (ll i = 0; i < n; i++) {
		cin >> d[i];
	}
}

int main() {
	fast;
	for (;;) {
		read();
		solve();
	}
	return 0;
}


// ...
#pragma GCC optimize("Ofast", "unroll-loops")
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(a) (ll)((a).size())
#define heap priority_queue
#define hash_map unordered_map
#define hash_set unordered_set
#define ft first
#define sd second
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define mineq(a, b) (a) = min((a), (b))
#define maxeq(a, b) (a) = max((a), (b))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef vector<ll> vll;
typedef set<ll> sll;
typedef map<ll, ll> mll;
const ll inf = numeric_limits<ll>::max() / 2;
const ld eps = 1e-9;
const ld pi = acos(-1);

const ll R = 1e9 + 7;
const ll K = 100;

ll n, x;
vll d, dist, dp;
vector<vll> matrix(K + 2, vll(K + 2, 0));
vector<vll> beg(K + 2, vll(1, 0));

void gen() {
	for (ll i = 0; i <= K; i++) {
		matrix[i][i + 1] = 1;
	}
	for (ll i : d) {
		++matrix[K + 1][K + 1 - i];
	}
}

void genbeg() {
	beg[0][0] = 1;
	for (ll i = 0; i <= K; i++) {
		for (ll j : d) {
			if (i - j >= 0) {
				beg[i][0] += beg[i - j][0];
				beg[i][0] %= R;
			}
		}
	}
	for (ll i = 1; i <= K; i++) {
		beg[i][0] += beg[i - 1][0];
		beg[i][0] %= R;
	}
}

vector<vll> mult(vector<vll> &a, vector<vll> &b) {
	ll n = sz(a), m = sz(b[0]), l = sz(b);
	vector<vll> c(n, vll(m, 0));
	for (ll i = 0; i < n; i++) {
		for (ll j = 0; j < m; j++) {
			for (ll k = 0; k < l; k++) {
				c[i][j] += a[i][k] * b[k][j] % R;
				c[i][j] %= R;
			}
		}
	}
	return c;
}

vector<vll> binpow(vector<vll> &a, ll n) {
	if (n == 0) {
		vector<vll> unit(sz(a), vll(sz(a), 0));
		for (ll i = 0; i < sz(a); i++) {
			unit[i][i] = 1;
		}
		return unit;
	}
	if (n == 1) {
		return a;
	}
	vector<vll> ans = binpow(a, n / 2);
	ans = mult(ans, ans);
	if (n % 2 == 1) {
		ans = mult(ans, a);
	}
	return ans;
}

inline void solve() {
	gen();
	genbeg();
	vector<vll> a = binpow(matrix, x);
	a = mult(a, beg);
	ll ans = a[0][0];
	cout << ans << endl;
}

inline void read() {
	cin >> n >> x;
	d.resize(n);
	for (ll i = 0; i < n; i++) {
		cin >> d[i];
	}
}

int main() {
	fast;
	read();
	solve();
	return 0;
}


// ...
#pragma GCC optimize("Ofast", "unroll-loops")
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(a) (ll)((a).size())
#define heap priority_queue
#define hash_map unordered_map
#define hash_set unordered_set
#define ft first
#define sd second
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define mineq(a, b) (a) = min((a), (b))
#define maxeq(a, b) (a) = max((a), (b))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef vector<ll> vll;
typedef set<ll> sll;
typedef map<ll, ll> mll;
const ll inf = numeric_limits<ll>::max() / 2;
const ld eps = 1e-9;
const ld pi = acos(-1);

const ll R = 1e9 + 7;
const ll K = 100;

ll n, x;
vll d;
vector<vll> matrix(K + 3, vll(K + 3, 0));
vector<vll> beg(K + 3, vll(1, 0));

void gen() {
	for (ll i = 0; i <= K; i++) {
		matrix[i][i + 1] = 1;
	}
	for (ll i : d) {
		++matrix[K + 1][K + 1 - i + 1];
	}
	++matrix[K + 2][0];
	++matrix[K + 2][K + 2];
}

void genbeg() {
	beg[0][0] = 1;
	for (ll i = 1; i <= K + 1; i++) {
		for (ll j : d) {
			if (i - j >= 0) {
				beg[i][0] += beg[i - j][0];
				beg[i][0] %= R;
			}
		}
	}
}

vector<vll> mult(vector<vll> &a, vector<vll> &b) {
	ll n = sz(a), m = sz(b[0]), l = sz(b);
	vector<vll> c(n, vll(m, 0));
	for (ll i = 0; i < n; i++) {
		for (ll j = 0; j < m; j++) {
			for (ll k = 0; k < l; k++) {
				c[i][j] += a[i][k] * b[k][j] % R;
				c[i][j] %= R;
			}
		}
	}
	return c;
}

vector<vll> binpow(vector<vll> &a, ll n) {
	if (n == 0) {
		vector<vll> unit(sz(a), vll(sz(a), 0));
		for (ll i = 0; i < sz(a); i++) {
			unit[i][i] = 1;
		}
		return unit;
	}
	if (n == 1) {
		return a;
	}
	vector<vll> ans = binpow(a, n / 2);
	ans = mult(ans, ans);
	if (n % 2 == 1) {
		ans = mult(ans, a);
	}
	return ans;
}

inline void solve() {
	for (ll i = 0; i < sz(matrix); i++) {
		for (ll j = 0; j < sz(matrix); j++) {
			matrix[i][j] = 0;
		}
	}
	for (ll i = 0; i < sz(beg); i++) {
		beg[i][0] = 0;
	}
	gen();
	genbeg();
	vector<vll> a = binpow(matrix, x);
	a = mult(a, beg);
	ll ans = (a[0][0] + a.back()[0]) % R;
	cout << ans << endl;
}

inline void read() {
	cin >> n >> x;
	d.assign(n, 0);
	for (ll i = 0; i < n; i++) {
		cin >> d[i];
	}
}

int main() {
	fast;
	read();
	solve();
	return 0;
}


// ...
#pragma GCC optimize("Ofast", "unroll-loops")
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(a) (ll)((a).size())
#define heap priority_queue
#define hash_map unordered_map
#define hash_set unordered_set
#define ft first
#define sd second
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define mineq(a, b) (a) = min((a), (b))
#define maxeq(a, b) (a) = max((a), (b))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef vector<ll> vll;
typedef set<ll> sll;
typedef map<ll, ll> mll;
const ll inf = numeric_limits<ll>::max() / 2;
const ld eps = 1e-9;
const ld pi = acos(-1);

const ll R = 1e9 + 7;
const ll K = 100;

ll n, x;
vll d, dist, dp;
vector<vll> matrix(K + 2, vll(K + 2, 0));
vector<vll> beg(K + 2, vll(1, 0));

void gen() {
	for (ll i = 0; i <= K; i++) {
		matrix[i][i + 1] = 1;
	}
	for (ll i : d) {
		++matrix[K + 1][K + 1 - i];
	}
}

void genbeg() {
	beg[0][0] = 1;
	for (ll i = 0; i <= K; i++) {
		for (ll j : d) {
			if (i - j >= 0) {
				beg[i][0] += beg[i - j][0];
				beg[i][0] %= R;
			}
		}
	}
	for (ll i = 1; i <= K; i++) {
		beg[i][0] += beg[i - 1][0];
	}
}

vector<vll> mult(vector<vll> &a, vector<vll> &b) {
	ll n = sz(a), m = sz(b[0]), l = sz(b);
	vector<vll> c(n, vll(m, 0));
	for (ll i = 0; i < n; i++) {
		for (ll j = 0; j < m; j++) {
			for (ll k = 0; k < l; k++) {
				c[i][j] += a[i][k] * b[k][j];
				c[i][j] %= R;
			}
		}
	}
	return c;
}

vector<vll> binpow(vector<vll> &a, ll n) {
	if (n == 0) {
		vector<vll> unit(sz(a), vll(sz(a), 0));
		for (ll i = 0; i < sz(a); i++) {
			unit[i][i] = 1;
		}
		return unit;
	}
	if (n == 1) {
		return a;
	}
	vector<vll> ans = binpow(a, n / 2);
	ans = mult(ans, ans);
	if (n % 2 == 1) {
		ans = mult(ans, a);
	}
	return ans;
}

inline void solve() {
	gen();
	genbeg();
	vector<vll> a = binpow(matrix, x);
	a = mult(a, beg);
	ll ans = a[0][0];
	cout << ans << endl;
}

inline void read() {
	cin >> n >> x;
	d.resize(n);
	for (ll i = 0; i < n; i++) {
		cin >> d[i];
	}
}

int main() {
	fast;
	read();
	solve();
	return 0;
}


// ...
#pragma GCC optimize("Ofast", "unroll-loops")
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(a) (ll)((a).size())
#define heap priority_queue
#define hash_map unordered_map
#define hash_set unordered_set
#define ft first
#define sd second
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define mineq(a, b) (a) = min((a), (b))
#define maxeq(a, b) (a) = max((a), (b))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef vector<ll> vll;
typedef set<ll> sll;
typedef map<ll, ll> mll;
const ll inf = numeric_limits<ll>::max() / 2;
const ld eps = 1e-9;
const ld pi = acos(-1);

const ll R = 1e9 + 7;
const ll K = 100;

ll n, x;
vll d, dist, dp;
vector<vll> matrix(K + 2, vll(K + 2, 0));
vector<vll> beg(K + 2, vll(1, 0));

void gen() {
	for (ll i = 0; i <= K; i++) {
		matrix[i][i + 1] = 1;
	}
	for (ll i : d) {
		++matrix[K + 1][K + 2 - i];
	}
}

void genbeg() {
	beg[0][0] = 1;
	for (ll i = 0; i <= K + 1; i++) {
		for (ll j : d) {
			if (i - j >= 0) {
				beg[i][0] += beg[i - j][0];
				beg[i][0] %= R;
			}
		}
	}
	for (ll i = 1; i <= K + 1; i++) {
		beg[i][0] += beg[i - 1][0];
		beg[i][0] %= R;
	}
}

vector<vll> mult(vector<vll> &a, vector<vll> &b) {
	ll n = sz(a), m = sz(b[0]), l = sz(b);
	vector<vll> c(n, vll(m, 0));
	for (ll i = 0; i < n; i++) {
		for (ll j = 0; j < m; j++) {
			for (ll k = 0; k < l; k++) {
				c[i][j] += a[i][k] * b[k][j] % R;
				c[i][j] %= R;
			}
		}
	}
	return c;
}

vector<vll> binpow(vector<vll> &a, ll n) {
	if (n == 0) {
		vector<vll> unit(sz(a), vll(sz(a), 0));
		for (ll i = 0; i < sz(a); i++) {
			unit[i][i] = 1;
		}
		return unit;
	}
	if (n == 1) {
		return a;
	}
	vector<vll> ans = binpow(a, n / 2);
	ans = mult(ans, ans);
	if (n % 2 == 1) {
		ans = mult(ans, a);
	}
	return ans;
}

inline void solve() {
	gen();
	genbeg();
	vector<vll> a = binpow(matrix, x);
	a = mult(a, beg);
	ll ans = a[0][0];
	cout << ans << endl;
}

inline void read() {
	cin >> n >> x;
	d.resize(n);
	for (ll i = 0; i < n; i++) {
		cin >> d[i];
	}
}

int main() {
	fast;
	read();
	solve();
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int N = 205;
const int mod = 1e9 + 7;

int n;
int cnt[N];
int dp[N], sum[N];
vector<vector<int>> I;

void init()
{
  I.clear();
  for(int i = 0 ; i <= 100 ; i++){
    I.push_back(vector<int>(101));
    for(int j = 0 ; j <= 100 ; j++)
      I[i][j] = i == j;
  }
}

vector<vector<int>> Mult(vector<vector<int>>& A, vector<vector<int>>& B)
{
  assert(A[0].size() == B.size());
  vector<vector<int>> R(A.size(), vector<int>(B[0].size()));
  for(int i = 0 ; i < (int)A.size() ; i++)
    for(int j = 0 ; j < (int)B[0].size() ; j++){
      R[i][j] = 0;
      for(int k = 0 ; k < (int)B.size() ; k++){
        R[i][j] += 1LL * A[i][k] * B[k][j] % mod;
        R[i][j] %= mod;
      }
    }
  return R;
}

vector<vector<int>> Pow(vector<vector<int>>& A, int p)
{
  if(!p)
    return I;
  vector<vector<int>> R = Pow(A, p >> 1);
  R = Mult(R, R);
  if(p & 1)
    R = Mult(R, A);
  return R;
}

int solve(int x)
{
  assert(x >= 100);
  vector<vector<int>> M(101, vector<int>(101, 0));
  M[0][0] = 1;
  for(int i = 1 ; i <= 100 ; i++){
    if(i < 100)
      M[i + 1][i] = 1;
    M[0][i] = M[1][i] = cnt[i];
  }
  M = Pow(M, x - 100);
  int res = 1LL * M[0][0] * sum[100] % mod;
  for(int i = 1 ; i <= 100 ; i++)
    res = (res + 1LL * M[0][i] * dp[101 - i] % mod) % mod;
  return res;
}

int main()
{
  int x;
  init();
  cin >> n >> x;
  for(int i = 0 ; i < n ; i++){
    int a; cin >> a;
    cnt[a]++;
  }
  dp[0] = sum[0] = 1;
  for(int i = 1 ; i <= 200 ; i++){
    for(int j = 1 ; j <= i ; j++)
      dp[i] += 1LL * cnt[j] * dp[i - j] % mod, dp[i] %= mod;
    sum[i] = (sum[i - 1] + dp[i]) % mod;
  }
  if(x <= 100)
    return cout << sum[x] << endl, 0;
  cout << solve(x) << endl;
}


#include<bits/stdc++.h>
using namespace std;
const int lim=102,mod=1e9+7;
long long original[lim][lim],ans[lim][lim],help[lim][lim];
void make()
{
for(int i=1;i<lim;i++)
    original[i-1][i]=1;
for(int i=lim-2;i>=1;i--)
    original[i][1]=1;
original[lim-1][lim-1]=1;
}
void mult_original()
{
    memset(help,0,sizeof(help));
    for(int i=0;i<lim;i++)
        for(int j=0;j<lim;j++)
            for(int k=0;k<lim;k++)
            help[i][j]=(help[i][j]+original[i][k]*original[k][j])%mod;
    for(int i=0;i<lim;i++)
        for(int j=0;j<lim;j++)
            original[i][j]=help[i][j];
}
void mult_ans()
{
    memset(help,0,sizeof(help));
    for(int i=0;i<lim;i++)
        for(int j=0;j<lim;j++)
            for(int k=0;k<lim;k++)
            help[i][j]=(help[i][j]+ans[i][k]*original[k][j])%mod;
    for(int i=0;i<lim;i++)
        for(int j=0;j<lim;j++)
            ans[i][j]=help[i][j];
}
int main()
{
int n,x,d;
make();
cin>>n>>x;
for(int i=1;i<=n;i++)
{
    cin>>d;
    original[d][lim-1]++;
}

for(int i=0;i<lim;i++)
    ans[i][i]=1;

x++;
while(x)
{
    if(x%2==1)
        mult_ans();
    mult_original();
    x=x/2;
}
cout<<(ans[0][lim-1]+1)%mod<<endl;
return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int lim=102,mod=1e9+7;
long long original[lim][lim],ans[lim][lim],help[lim][lim];
void make()
{
for(int i=1;i<lim-1;i++)
    original[i-1][i]=1;
original[lim-1][lim-1]=1;
}
void mult_original()
{
    memset(help,0,sizeof(help));
    for(int i=0;i<lim;i++)
        for(int j=0;j<lim;j++)
            for(int k=0;k<lim;k++)
            help[i][j]=(help[i][j]+original[i][k]*original[k][j])%mod;
    for(int i=0;i<lim;i++)
        for(int j=0;j<lim;j++)
            original[i][j]=help[i][j];
}
void mult_ans()
{
    memset(help,0,sizeof(help));
    for(int i=0;i<lim;i++)
        for(int j=0;j<lim;j++)
            for(int k=0;k<lim;k++)
            help[i][j]=(help[i][j]+ans[i][k]*original[k][j])%mod;
    for(int i=0;i<lim;i++)
        for(int j=0;j<lim;j++)
            ans[i][j]=help[i][j];
}
int main()
{
int n,x,d;
make();
cin>>n>>x;
for(int i=1;i<=n;i++)
{
    cin>>d;
    original[d][lim-1]++;
    original[d][1]++;
}

for(int i=0;i<lim;i++)
    ans[i][i]=1;

x++;
while(x)
{
    if(x%2==1)
        mult_ans();
    mult_original();
    x=x/2;
}
cout<<(ans[0][lim-1]+1)%mod<<endl;
return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

template<int m>
struct modint {

	unsigned x;

	modint() : x(0) {}

	modint(long long arg) {
		arg %= m;
		if (arg < 0) {
			x = arg + m;
		} else {
			x = arg;
		}
	}

	modint& operator+= (const modint& other) {
		x += other.x;
		if (x >= m) {
			x -= m;
		}
		return *this;
	}

	modint& operator*= (const modint& other) {
		x = (x * 1ll * other.x) % m;
		return *this;
	}

	modint& operator-= (const modint& other) {
		x += m - other.x;
		if (x >= m) {
			x -= m;
		}
		return *this;
	}

	modint operator+ (const modint& other) const {
		modint tmp = *this;
		tmp += other;
		return tmp;
	}

	modint operator- (const modint& other) const {
		modint tmp = *this;
		tmp -= other;
		return tmp;
	}

	modint operator* (const modint& other) const {
		modint tmp = *this;
		tmp *= other;
		return tmp;
	}

	explicit operator int () const {
		return x;
	}

	modint& operator++ () {
		++x;
		if (x == m) {
			x = 0;
		}
		return *this;
	}

	modint& operator-- () {
		if (x == 0) {
			x = m-1;
		} else {
			--x;
		}
		return *this;
	}

	modint operator++ (int) {
		modint tmp = *this;
		++*this;
		return tmp;
	}

	modint operator-- (int) {
		modint tmp = *this;
		--*this;
		return tmp;
	}

	bool operator== (const modint& other) const {
		return x == other.x;
	}

	bool operator!= (const modint& other) const {
		return x != other.x;
	}

	template<class T>
	modint operator^ (T arg) const {
		if (arg == 0) {
			return 1;
		}
		if (arg == 1) {
			return x;
		}
		auto t = *this ^ (arg >> 1);
		t *= t;
		if (arg & 1) {
			t *= *this;
		}
		return t;
	}

	modint inv() const {
		return *this ^ (m-2);
	}
};

const int MOD = 1'000'000'007;
typedef modint<MOD> mint;

typedef vector<mint> vec;
typedef vector<vec> mat;

mat ident(int k) {
	mat a(k, vec(k));
	for (int i=0; i<k; i++)
		a[i][i] = 1;
	return a;
}

mat zero(int k) {
	return mat(k, vec(k));
}

mat mul(mat a, mat b) {
	int n = a.size();
	mat c = zero(n);
	for (int i=0; i<n; i++)
		for (int j=0; j<n; j++)
			for (int k=0; k<n; k++)
				c[i][k] += a[i][j] * b[j][k];
	return c;
}

mat pw(mat a, int k) {
	if (k == 0)
		return ident(a.size());
	if (k == 1)
		return a;

	auto b = pw(a, k >> 1);
	b = mul(b, b);
	if (k & 1)
		b = mul(b, a);
	return b;
}

int n, x;
int d[1000005];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.tie(nullptr);

	cin >> n >> x;
	for (int i=0; i<n; i++)
		cin >> d[i];

	mat a = zero(111);
	for (int i=0; i<110; i++)
		a[i][i+1] = 1;
	for (int i=0; i<n; i++) {
		a[110][111 - d[i]] += 1;
		a[110][110 - d[i]] -= 1;
	}
	a[110][110] += 1;

	auto b = pw(a, x);
	// resenje je b.v[110] gde je v = {0, ..., 1}

	// ofstream fout("tmp");
	// for (int i=0; i<111; i++)
	// 	for (int j=0; j<111; j++)
	// 		fout << (int)b[i][j] << " \n"[j == 110];

	cout << (int)b[110][110] << '\n';
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

template<int m>
struct modint {

	unsigned x;

	modint() : x(0) {}

	modint(long long arg) {
		arg %= m;
		if (arg < 0) {
			x = arg + m;
		} else {
			x = arg;
		}
	}

	modint& operator+= (const modint& other) {
		x += other.x;
		if (x >= m) {
			x -= m;
		}
		return *this;
	}

	modint& operator*= (const modint& other) {
		x = (x * 1ll * other.x) % m;
		return *this;
	}

	modint& operator-= (const modint& other) {
		x += m - other.x;
		if (x >= m) {
			x -= m;
		}
		return *this;
	}

	modint operator+ (const modint& other) const {
		modint tmp = *this;
		tmp += other;
		return tmp;
	}

	modint operator- (const modint& other) const {
		modint tmp = *this;
		tmp -= other;
		return tmp;
	}

	modint operator* (const modint& other) const {
		modint tmp = *this;
		tmp *= other;
		return tmp;
	}

	explicit operator int () const {
		return x;
	}

	modint& operator++ () {
		++x;
		if (x == m) {
			x = 0;
		}
		return *this;
	}

	modint& operator-- () {
		if (x == 0) {
			x = m-1;
		} else {
			--x;
		}
		return *this;
	}

	modint operator++ (int) {
		modint tmp = *this;
		++*this;
		return tmp;
	}

	modint operator-- (int) {
		modint tmp = *this;
		--*this;
		return tmp;
	}

	bool operator== (const modint& other) const {
		return x == other.x;
	}

	bool operator!= (const modint& other) const {
		return x != other.x;
	}

	template<class T>
	modint operator^ (T arg) const {
		if (arg == 0) {
			return 1;
		}
		if (arg == 1) {
			return x;
		}
		auto t = *this ^ (arg >> 1);
		t *= t;
		if (arg & 1) {
			t *= *this;
		}
		return t;
	}

	modint inv() const {
		return *this ^ (m-2);
	}
};

const int MOD = 1'000'000'007;
typedef modint<MOD> mint;

typedef vector<mint> vec;
typedef vector<vec> mat;

mat ident(int k) {
	mat a(k, vec(k));
	for (int i=0; i<k; i++)
		a[i][i] = 1;
	return a;
}

mat zero(int k) {
	return mat(k, vec(k));
}

mat mul(mat a, mat b) {
	int n = a.size();
	mat c = zero(n);
	for (int i=0; i<n; i++)
		for (int j=0; j<n; j++)
			for (int k=0; k<n; k++)
				c[i][k] += a[i][j] * b[j][k];
	return c;
}

mat pw(mat a, int k) {
	if (k == 0)
		return ident(a.size());
	if (k == 1)
		return a;

	auto b = pw(a, k >> 1);
	b = mul(b, b);
	if (k & 1)
		b = mul(b, a);
	return b;
}

int n, x;
int d[105];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.tie(nullptr);

	cin >> n >> x;
	for (int i=0; i<n; i++)
		cin >> d[i];

	mat a = zero(111);
	for (int i=0; i<110; i++)
		a[i][i+1] = 1;
	for (int i=0; i<n; i++) {
		a[110][111 - d[i]] += 1;
		a[110][110 - d[i]] -= 1;
	}
	a[110][110] += 1;

	auto b = pw(a, x);
	// resenje je b.v[110] gde je v = {0, ..., 1}

	// ofstream fout("tmp");
	// for (int i=0; i<111; i++)
	// 	for (int j=0; j<111; j++)
	// 		fout << (int)b[i][j] << " \n"[j == 110];

	cout << (int)b[110][110] << '\n';
}


#include <iostream>
#include <string>
#include <set>

using namespace std;

const int N = 101;
const int p = 1000000007;

struct matrix {
    matrix() {
        for (int i = 0; i < N; i++)
            for (int j = 0; j < N; j++)
                a[i][j] = 0;
    }
    long long a[101][101];
    matrix operator * (matrix m) {
        matrix t;
        for (int i = 0; i < N; i++)
            for (int j = 0; j < N; j++) {
                t.a[i][j] = 0;
                for (int k = 0; k < N; k++)
                    t.a[i][j] = (t.a[i][j] + a[i][k] * m.a[k][j]) % p;
            }
        return t;
    }
};

matrix E;

matrix Pow(matrix m, int b) {
    if (b == 0) return E;
    if (b & 1) return m * Pow(m, b - 1);
    matrix tmp = Pow(m, b / 2);
    return tmp * tmp;
}

int main()
{

    for (int i = 0; i < N; i++)
        E.a[i][i] = 1;

    int n, x;
    cin >> n >> x;

    int a[1000];
    for (int i = 0; i < 1000; i++) a[i] = 0;

    for (int i = 0; i < n; i++) {
        int t;
        cin >> t;
        a[t - 1]++;
    }

    matrix q;
    q.a[0][0] = q.a[1][0] = 1;
    for (int i = 1; i < N; i++)
        q.a[i][1] = a[i - 1];
    for (int i = 2; i < N; i++)
        q.a[i - 1][i] = 1;

    q = Pow(q, x + 1);
    cout << (q.a[1][0]) % p;

    return 0;
}


#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v, w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;
int INF = INT_MAX / 2;

vector< vector<ll> > matmul(vector< vector<ll> >& A, vector< vector<ll> >& B) {
	int n = A.size();
	vector< vector<ll> > C(n, vector<ll>(n));
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			for (int k = 0; k < n; k++)
				C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % MOD;
	return C;
}

vector< vector<ll> > matpow(vector< vector<ll> > A, ll x) {
	int n = A.size();
	vector< vector<ll> > B(n, vector<ll>(n));
	for (int i = 0; i < n; i++) B[i][i] = 1;
	while (x > 0) {
		if (x % 2) B = matmul(B, A);
		x /= 2;
		A = matmul(A, A);
	}
	return B;
}

int main() {
	int n, x; cin >> n >> x;
	vector<int> a(100);
	while (n--) {
		int d; scanf("%d", &d);
		a[d - 1]++;
	}
	vector<vector<ll> > A(101, vector<ll>(101));
	for (int i = 0; i < 100; i++)
		A[0][i] = a[i];
	A[0][100] = 1;
	for (int i = 0; i < 99; i++)
		A[i + 1][i] = 1;
	A[100][100] = 1;
	vector<vector<ll> > B = matpow(A, x + 1);
	cout << B[0][100] << endl;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <unordered_set>

using namespace std;
const int N = 101;
const int MOD = 1e9 + 7;

int dp[N];
int n, x, sum;
int cnt[N];
int tmp[N][N];
int res[N][N];
int c[N][N];

int solve(int p)
{
	memset(tmp, 0, sizeof(tmp));
	memset(res, 0, sizeof(res));
	tmp[0][0] = 1;
	for (int i = 1; i < N; ++i)
		tmp[0][i] = cnt[N - i];
	for (int i = 1; i < N - 1; ++i)
		tmp[i][i + 1] = 1;
	for (int i = 1; i < N; ++i)
		tmp[100][i] = cnt[N - i];
	for (int i = 0; i < N; ++i)
		res[i][i] = 1;
	while (p > 0)
	{
		if (p % 2 == 1)
		{
			for (int i = 0; i < N; ++i)
			{
				for (int j = 0; j < N; ++j)
				{
					c[i][j] = 0;
					for (int k = 0; k < N; ++k)
						c[i][j] = (c[i][j] + 1ll * res[i][k] * tmp[k][j]) % MOD;
				}
			}
			for (int i = 0; i < N; ++i)
			{
				for (int j = 0; j < N; ++j)
					res[i][j] = c[i][j];
			}
		}
		for (int i = 0; i < N; ++i)
			{
				for (int j = 0; j < N; ++j)
				{
					c[i][j] = 0;
					for (int k = 0; k < N; ++k)
						c[i][j] = (c[i][j] + 1ll * tmp[i][k] * tmp[k][j]) % MOD;
				}
			}
		for (int i = 0; i < N; ++i)
		{
			for (int j = 0; j < N; ++j)
				tmp[i][j] = c[i][j];
		}
		p /= 2;
	}
	int ans = 1ll * sum * res[0][0] % MOD;
	//cout << ans << endl;
	for (int i = 1; i < N; ++i)
		ans = (ans + 1ll * dp[i] * res[0][i]) % MOD;
	return ans;
}

int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
/*#else
	freopen(TASK".in", "r", stdin);
	freopen(TASK".out", "w", stdout);*/
#endif
	scanf("%d%d", &n, &x);
	for (int i = 0; i < n; ++i)
	{
		int a; scanf("%d", &a);
		cnt[a]++;
	}
	dp[0] = sum = 1;
	for (int i = 1; i <= min(x, 100); ++i)
	{
		dp[i] = 0;
		for (int j = 1; j <= 100; ++j)
		{
			if (i - j >= 0)
				dp[i] += 1ll * cnt[j] * dp[i - j] % MOD;
			dp[i] %= MOD;
		}
		sum = (sum + dp[i]) % MOD;
	}
	if (x < 100)
		cout << sum << endl;
	else
		cout << solve(x - 100) << endl;

	return 0;
}


#include <cstdio>

#define LL __int64

const int mod = 1000000007;
const int N = 101;
int n, m, cnt[N];

struct Matrix {
	int a[N][N];
	void toZero() {
		for(int i = 0; i < N; ++i)
			for(int j = 0; j < N; ++j)
				a[i][j] = 0;
	}

	void toOne() {
		for(int i = 0; i < N; ++i)
			for(int j = 0; j < N; ++j)
				a[i][j] = (int)(i == j);
	}

	Matrix operator * (const Matrix &B) const {
		int i, j, k;
		Matrix A(*this), C;
		C.toZero();
		for(i = 0; i < N; ++i) {
			for(j = 0; j < N; ++j) {
				if(A.a[i][j] == 0) continue;
				for(k = 0; k < N; ++k)
					C.a[i][k] = (C.a[i][k] + (LL)A.a[i][j] * B.a[j][k] % mod) % mod;
			}
		}
		return C;
	}

	Matrix operator ^ (int p) const {
		Matrix X(*this), R;
		R.toOne();
		for(; p != 0; p >>= 1) {
			if(p & 1) R = R * X;
			X = X * X;
		}
		return R;
	}
}st, qkm;

void GetData() {
	scanf("%d%d", &n, &m);
	for(int t; n--; ) {
		scanf("%d", &t);
		cnt[t]++;
	}
}

void Solve() {
	int i, j;
	st.toZero();  qkm.toZero();
	st.a[99][0] = 1; st.a[100][0] = 1;
	for(i = 0; i < 99; ++i)
		qkm.a[i][i + 1] = 1;
	for(i = 1; i <= 100; ++i)
		qkm.a[99][100 - i] = qkm.a[100][100 - i] = cnt[i];
	qkm.a[100][100] = 1;
	qkm = qkm ^ m;
	st = qkm * st;
	printf("%d\n", st.a[100][0]);
}

int main() {
	GetData();
	Solve();
	return 0;
}


//In the name of Allah
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<iterator>
#include<cmath>
#include<string>
#include<sstream>
#include<cstring>
#include<ctype.h>
#include<iomanip>
#include<functional>
#include<bitset>
#include<stdio.h>
#include<fstream>
#include<stdlib.h>
#include<math.h>
#include<ctime>
#include<string>
#include<cstdio>
#include<locale>
#include<codecvt>
using namespace std;
#define lop(i,a,n) for(int i=a;i<n;++i)
#define loop(i,n,a)for(int i=n-1;i>=a;--i)
#define R_(s)      freopen(s, "r", stdin)
#define W_(s)      freopen(s, "w", stdout)
#define R_W        R_("in.txt"),W_("out.txt")
#define ll         long long
#define ld         long double
#define ii         pair<ll,ll>
#define vii        vector<ii>
#define vi         vector<int>
#define vll        vector<ll>
#define vs         vector<string>
#define vvii       vector<vector<ii>>
#define vvi        vector<vector<int>>
#define vvll       vector<vector<ll>>
#define sz(v)      (ll)v.size()
#define all(v)     v.begin(),v.end()
#define sc(n)      scanf("%d",&n)
#define scl(n)     scanf("%lld",&n)
#define pr1(n)     printf("%d\n",n)
#define pr2(n)     printf("%d " ,n)
#define pr4(n)     printf("%lld\n",n)
#define pr3(n)     cout<<fixed<<setprecision(4)<<n<<endl
#define endl       "\n"
#define PI         2*acos(0.0)
#define DFS_GRAY  -1
#define DFS_WHITE  0
#define DFS_BLACK  1
#define oo  1e9
#define OO  1e18
#define EPS 1e-9
int dr[] = { 1, 0, -1, 0, -1, -1, 1, 1 };
int dc[] = { 0, -1, 0, 1, -1, 1, -1, 1 };
const int MAX = 1e6 + 7;
const int MOD = 1e9 + 7;
class matrix
{
public:
	vvll mat;
	matrix(ll n, ll m, ll num = -1)
	{
		mat.resize(n);
		if (num == -1)
			lop(i, 0, n) { mat[i].resize(m, 0); mat[i][i] = 1; }
		else
			lop(i, 0, n)mat[i].resize(m, num);
	}
	static vvll multi_matrix(vvll a, vvll b)
	{
		matrix c(a.size(), b[0].size(), 0);
		lop(i, 0, a.size())lop(j, 0, b[0].size())
		{
			lop(k, 0, b.size())c.mat[i][j] += (a[i][k]%MOD * b[k][j]%MOD) % MOD, c.mat[i][j] %= MOD;
		}
		return c.mat;
	}
	static vvll matrix_power(vvll a, ll k)
	{
		if (k == 0) { matrix c(a.size(), a.size()); return c.mat; }
		if (k % 2 == 1)return multi_matrix(a, matrix_power(a, k - 1));
		return matrix_power(multi_matrix(a, a), k / 2);
	}
};
ll cnt[110], dp[110];
void Solve(int x)
{
	dp[0] = 1;
	lop(i, 1, 101)lop(j, 1, i+1)
		dp[i] += (cnt[j] * dp[i - j]%MOD) % MOD, dp[i] %= MOD;
	if (x <= 100)return;
	ll sum = 1;
	matrix A(101, 101,0), B(101, 101,0);
	lop(i, 0, 100)A.mat[0][i] = dp[i + 1], sum += dp[i + 1];
	A.mat[0][100] = (sum%MOD);
	lop(i, 0, 99)B.mat[i + 1][i] = 1;
	lop(i, 0, 100)B.mat[i][99] = B.mat[i][100] = cnt[100 - i];
	B.mat[100][100] = 1;
	A.mat = matrix::multi_matrix(A.mat, matrix::matrix_power(B.mat, x - 100));
	cout << A.mat[0][100]%MOD << endl;
}
int main()
{
	int n, x, c;
	sc(n), sc(x);
	lop(i, 0, n)sc(c), cnt[c]++;
	Solve(x);
	if (x <= 100)
	{
		ll ans = 0;
		lop(i, 0, x+1)ans += dp[i], ans %= MOD;
		cout << ans << endl;
	}
}


//In the name of Allah
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<iterator>
#include<cmath>
#include<string>
#include<sstream>
#include<cstring>
#include<ctype.h>
#include<iomanip>
#include<functional>
#include<bitset>
#include<stdio.h>
#include<fstream>
#include<stdlib.h>
#include<math.h>
#include<ctime>
#include<string>
#include<cstdio>
#include<locale>
#include<codecvt>
using namespace std;
#define lop(i,a,n) for(int i=a;i<n;++i)
#define loop(i,n,a)for(int i=n-1;i>=a;--i)
#define R_(s)      freopen(s, "r", stdin)
#define W_(s)      freopen(s, "w", stdout)
#define R_W        R_("in.txt"),W_("out.txt")
#define ll         long long
#define ld         long double
#define ii         pair<ll,ll>
#define vii        vector<ii>
#define vi         vector<int>
#define vll        vector<ll>
#define vs         vector<string>
#define vvii       vector<vector<ii>>
#define vvi        vector<vector<int>>
#define vvll       vector<vector<ll>>
#define sz(v)      (ll)v.size()
#define all(v)     v.begin(),v.end()
#define sc(n)      scanf("%d",&n)
#define scl(n)     scanf("%lld",&n)
#define pr1(n)     printf("%d\n",n)
#define pr2(n)     printf("%d " ,n)
#define pr4(n)     printf("%lld\n",n)
#define pr3(n)     cout<<fixed<<setprecision(4)<<n<<endl
#define endl       "\n"
#define PI         2*acos(0.0)
#define DFS_GRAY  -1
#define DFS_WHITE  0
#define DFS_BLACK  1
#define oo  1e9
#define OO  1e18
#define EPS 1e-9
int dr[] = { 1, 0, -1, 0, -1, -1, 1, 1 };
int dc[] = { 0, -1, 0, 1, -1, 1, -1, 1 };
const int MAX = 1e6 + 7;
const int MOD = 1e9 + 7;
class matrix
{
public:
	vvll mat;
	matrix(ll n, ll m, ll num = -1)
	{

		mat.resize(n);
		if (num == -1)
			lop(i, 0, n) { mat[i].resize(m, 0); mat[i][i] = 1; }
		else
			lop(i, 0, n)mat[i].resize(m, num);
	}
	static vvll multi_matrix(vvll a, vvll b)
	{
		matrix c(a.size(), b[0].size(), 0);
		lop(i, 0, a.size())lop(j, 0, b[0].size())
		{
			lop(k, 0, b.size())c.mat[i][j] += (a[i][k] * b[k][j]) % MOD, c.mat[i][j] %= MOD;
		}
		return c.mat;
	}
	static vvll matrix_power(vvll a, ll k)
	{
		if (k == 0) { matrix c(a.size(), a.size()); return c.mat; }
		if (k % 2 == 1)return multi_matrix(a, matrix_power(a, k - 1));
		return matrix_power(multi_matrix(a, a), k / 2);
	}
};
int cnt[110], dp[110];
void Solve(int x)
{
	dp[0] = 1;
	lop(i, 1, 101)lop(j, 1, i+1)
		dp[i] += (cnt[j] * dp[i - j]) % MOD, dp[i] %= MOD;
	if (x <= 100)return;
	ll sum = 0;
	matrix A(101, 101,0), B(101, 101,0);
	lop(i, 0, 100)A.mat[0][i] = dp[i + 1], sum += dp[i + 1];
	A.mat[0][100] = (sum%MOD);
	lop(i, 0, 99)B.mat[i + 1][i] = 1;
	lop(i, 0, 100)B.mat[i][99] = B.mat[i][100] = cnt[100 - i];
	B.mat[100][100] = 1;
	A.mat = matrix::multi_matrix(A.mat, matrix::matrix_power(B.mat, x - 100));
	cout << A.mat[0][100]%MOD << endl;
}
int main()
{
	int n, x, c;
	sc(n), sc(x);
	lop(i, 0, n)sc(c), cnt[c]++;
	Solve(x);
	if (x <= 100)
	{
		ll ans = 0;
		lop(i, 0, x+1)ans += dp[i], ans %= MOD;
		cout << ans << endl;
	}
}


//In the name of Allah
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<iterator>
#include<cmath>
#include<string>
#include<sstream>
#include<cstring>
#include<ctype.h>
#include<iomanip>
#include<functional>
#include<bitset>
#include<stdio.h>
#include<fstream>
#include<stdlib.h>
#include<math.h>
#include<ctime>
#include<string>
#include<cstdio>
#include<locale>
#include<codecvt>
using namespace std;
#define lop(i,a,n) for(int i=a;i<n;++i)
#define loop(i,n,a)for(int i=n-1;i>=a;--i)
#define R_(s)      freopen(s, "r", stdin)
#define W_(s)      freopen(s, "w", stdout)
#define R_W        R_("in.txt"),W_("out.txt")
#define ll         long long
#define ld         long double
#define ii         pair<ll,ll>
#define vii        vector<ii>
#define vi         vector<int>
#define vll        vector<ll>
#define vs         vector<string>
#define vvii       vector<vector<ii>>
#define vvi        vector<vector<int>>
#define vvll       vector<vector<ll>>
#define sz(v)      (ll)v.size()
#define all(v)     v.begin(),v.end()
#define sc(n)      scanf("%d",&n)
#define scl(n)     scanf("%lld",&n)
#define pr1(n)     printf("%d\n",n)
#define pr2(n)     printf("%d " ,n)
#define pr4(n)     printf("%lld\n",n)
#define pr3(n)     cout<<fixed<<setprecision(4)<<n<<endl
#define endl       "\n"
#define PI         2*acos(0.0)
#define DFS_GRAY  -1
#define DFS_WHITE  0
#define DFS_BLACK  1
#define oo  1e9
#define OO  1e18
#define EPS 1e-9
int dr[] = { 1, 0, -1, 0, -1, -1, 1, 1 };
int dc[] = { 0, -1, 0, 1, -1, 1, -1, 1 };
const int MAX = 1e6 + 7;
const int MOD = 1e9 + 7;
class matrix
{
public:
	vvll mat;
	matrix(ll n, ll m, ll num = -1)
	{

		mat.resize(n);
		if (num == -1)
			lop(i, 0, n) { mat[i].resize(m, 0); mat[i][i] = 1; }
		else
			lop(i, 0, n)mat[i].resize(m, num);
	}
	static vvll multi_matrix(vvll a, vvll b)
	{
		matrix c(a.size(), b[0].size(), 0);
		lop(i, 0, a.size())lop(j, 0, b[0].size())
		{
			lop(k, 0, b.size())c.mat[i][j] += (a[i][k] * b[k][j]) % MOD, c.mat[i][j] %= MOD;
		}
		return c.mat;
	}
	static vvll matrix_power(vvll a, ll k)
	{
		if (k == 0) { matrix c(a.size(), a.size()); return c.mat; }
		if (k % 2 == 1)return multi_matrix(a, matrix_power(a, k - 1));
		return matrix_power(multi_matrix(a, a), k / 2);
	}
};
int cnt[110], dp[110];
void Solve(int x)
{
	dp[0] = 1;
	lop(i, 1, 101)lop(j, 1, i+1)
		dp[i] += (cnt[j] * dp[i - j]) % MOD, dp[i] %= MOD;
	if (x <= 100)return;
	ll sum = 1;
	matrix A(101, 101,0), B(101, 101,0);
	lop(i, 0, 100)A.mat[0][i] = dp[i + 1], sum += dp[i + 1];
	A.mat[0][100] = (sum%MOD);
	lop(i, 0, 99)B.mat[i + 1][i] = 1;
	lop(i, 0, 100)B.mat[i][99] = B.mat[i][100] = cnt[100 - i];
	B.mat[100][100] = 1;
	A.mat = matrix::multi_matrix(A.mat, matrix::matrix_power(B.mat, x - 100));
	cout << A.mat[0][100]%MOD << endl;
}
int main()
{
	int n, x, c;
	sc(n), sc(x);
	lop(i, 0, n)sc(c), cnt[c]++;
	Solve(x);
	if (x <= 100)
	{
		ll ans = 0;
		lop(i, 0, x+1)ans += dp[i], ans %= MOD;
		cout << ans << endl;
	}
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>

using namespace std;
typedef long long int64;

int n, x;
const int maxn = 100;
const int64 MOD = (int64)1e9 + 7;
int64 d[maxn+1];
int64 A[maxn+1][maxn+1];
int64 ret[maxn+1][maxn+1];
int64 base[maxn+1][maxn+1];
int64 tmp[maxn+1][maxn+1];
int64 X[1][maxn+1];

void mul(int64 a[][maxn+1], int64 b[][maxn+1]) {
  for (int i = 0; i < maxn+1; ++ i) {
    for (int j = 0; j < maxn+1; ++ j) {
      tmp[i][j] = 0;
      for (int k = 0; k < maxn+1; ++ k) {
        tmp[i][j] += a[i][k] * b[k][j];
        tmp[i][j] %= MOD;
      }
    }
  }
  memcpy(a, tmp, sizeof(tmp));
}

void solve() {
  cin >> n >> x;
  int64 t;
  memset(d, 0, sizeof(d));
  for (int i = 0; i < n; ++ i) {
    cin >> t;
    ++ d[t];
  }

  memset(A, 0, sizeof(A));
  memset(X[0], 0, sizeof(X[0]));
  X[0][maxn] = 1;

  for (int i = 0; i < maxn-1; ++ i) {
    A[i+1][i] = 1;
  }

  for (int i = 0; i < maxn; ++ i) {
    A[i][maxn-1] = d[maxn-i];
  }

  A[maxn][maxn-1] = 1;
  A[maxn][maxn] = 1;

  memcpy(ret, A, sizeof(A));
  memcpy(base, A, sizeof(A));

  while (x) {
    if (x&1) {
      mul(ret, base);
    }
    mul(base, base);
    x >>= 1;
  }

  int64 ans = 0;
  for (int i = 0; i < maxn+1; ++ i) {
    ans += X[0][i]* ret[i][maxn-1];
    ans %= MOD;
  }
  cout << ans << endl;
}

int main() {
  solve();
  return 0;
}


#include <iostream>
#include <map>

using namespace std;
const int size = 101;
typedef int** matrix;

matrix new_matrix() {
    matrix res = new int*[size];
    for (int i = 0; i < size; ++i) {
        res[i] = new int[size];
        for (int j = 0; j < size; ++j) {
            res[i][j] = 0;
        }
    }
    return res;
}

matrix mult(matrix a, matrix b) {
    matrix res = new_matrix();
    for (int i = 0; i < size; ++i) {
        for (int j = 0; j < size; ++j) {
            for (int k = 0; k < size; ++k) {
                res[i][j] += a[i][k] * b[k][j];
            }
        }
    }
    return res;
}

matrix binpow(matrix a, int n) {
    if (n == 0) {
        matrix res = new_matrix();
        for (int i = 0; i < size; ++i) {
            res[i][i] = 1;
        }
        return res;
    } else if (n % 2 == 1) {
        matrix t = binpow(a, n / 2);
        return mult(a, mult(t, t));
    } else {
        matrix t = binpow(a, n / 2);
        return mult(t, t);
    }
}

int main() {
    int n,  x;
    map<int, int> d;
    matrix next = new_matrix();
    matrix init = new_matrix();
    matrix far;
    cin >> n >> x;

// init ni - map
    for ( int i = 0; i < n; i++ ){
        int di;
        cin >> di;
        d[di] += 1;
    }
// init matrix
    for( int i = 0; i < size-2; i++ )
        next[i][i+1] = 1;
    for ( int i = 0; i < size-1; i++ )
        next[size-2][size-1-i] = d[i];

    next[size-1][size-2] = 1;
    next[size-1][size-1] = 1;
// init

    init[size-2][0] = 1;
    far = mult ( binpow(next, x+1), init);
    cout << far[size-1][0] << endl;
   // system("pause");
    return 0;
}


#include <iostream>
#include <map>

using namespace std;
const int size = 101;
typedef int** matrix;

matrix new_matrix() {
    matrix res = new int*[size];
    for (int i = 0; i < size; ++i) {
        res[i] = new int[size];
        for (int j = 0; j < size; ++j) {
            res[i][j] = 0;
        }
    }
    return res;
}

matrix mult(matrix a, matrix b) {
    matrix res = new_matrix();
    for (int i = 0; i < size; ++i) {
        for (int j = 0; j < size; ++j) {
            for (int k = 0; k < size; ++k) {
                res[i][j] += a[i][k] * b[k][j];
            }
        }
    }
    return res;
}

matrix binpow(matrix a, int n) {
    if (n == 0) {
        matrix res = new_matrix();
        for (int i = 0; i < size; ++i) {
            res[i][i] = 1;
        }
        return res;
    } else if (n % 2 == 1) {
        matrix t = binpow(a, n / 2);
        return mult(a, mult(t, t));
    } else {
        matrix t = binpow(a, n / 2);
        return mult(t, t);
    }
}

int main() {
    int n,  x;
    map<int, int> d;
    matrix next = new_matrix();
    matrix init = new_matrix();
    matrix far;
    cin >> n >> x;

// init ni - map
    for ( int i = 0; i < n; i++ ){
        int di;
        cin >> di;
        d[di] += 1;
    }
// init matrix
    for( int i = 0; i < size-2; i++ )
        next[i][i+1] = 1;
    for ( int i = 0; i < size-1; i++ )
        next[size-2][size-1-i] = d[i];

    next[size-1][size-2] = 1;
    next[size-1][size-1] = 1;
// init

    init[size-2][0] = 1;
    far = mult ( binpow(next, x+1), init);
    cout << far[size-1][0] << endl;
    system("pause");
    return 0;
}


#include <iostream>
#include <map>

using namespace std;
const int size = 101;
const long long mod = 1e9+7;
typedef long long** matrix;

matrix new_matrix() {
    matrix res = new long long*[size];
    for (int i = 0; i < size; ++i) {
        res[i] = new long long[size];
        for (int j = 0; j < size; ++j) {
            res[i][j] = 0;
        }
    }
    return res;
}

matrix mult(matrix a, matrix b) {
    matrix res = new_matrix();
    for (int i = 0; i < size; ++i)
        for (int j = 0; j < size; ++j)
            for (int k = 0; k < size; ++k) {
                res[i][j] += a[i][k] * b[k][j];
                res[i][j] %= mod;
            }
    return res;
}

matrix binpow(matrix a, int n) {
    if (n == 0) {
        matrix res = new_matrix();
        for (int i = 0; i < size; ++i) {
            res[i][i] = 1;
        }
        return res;
    } else if (n % 2 == 1) {
        matrix t = binpow(a, n / 2);
        return mult(a, mult(t, t));
    } else {
        matrix t = binpow(a, n / 2);
        return mult(t, t);
    }
}

int main() {
    int n,  x;
    map<int, int> d;
    matrix next = new_matrix();
    matrix init = new_matrix();
    matrix far;
    cin >> n >> x;

// init ni - map
    for ( int i = 0; i < n; i++ ){
        int di;
        cin >> di;
        d[di] += 1;
    }
// init matrix
    for( int i = 0; i < size-2; i++ )
        next[i][i+1] = 1;
    for ( int i = 0; i < size; i++ )
        next[size-2][size-1-i] = d[i];

    next[size-1][size-2] = 1;
    next[size-1][size-1] = 1;
// init

    init[size-2][0] = 1;
    far = mult ( binpow(next, x+1), init);
    cout << far[size-1][0] << endl;
    system("pause");
    return 0;
}


#include <iostream>
#include <map>

using namespace std;
const int size = 101;
const long long mod = 1e9+7;
typedef long long** matrix;

matrix new_matrix() {
    matrix res = new long long*[size];
    for (int i = 0; i < size; ++i) {
        res[i] = new long long[size];
        for (int j = 0; j < size; ++j) {
            res[i][j] = 0;
        }
    }
    return res;
}

matrix mult(matrix a, matrix b) {
    matrix res = new_matrix();
    for (int i = 0; i < size; ++i)
        for (int j = 0; j < size; ++j)
            for (int k = 0; k < size; ++k) {
                res[i][j] += a[i][k] * b[k][j];
                res[i][j] %= mod;
            }
    return res;
}

matrix binpow(matrix a, int n) {
    if (n == 0) {
        matrix res = new_matrix();
        for (int i = 0; i < size; ++i) {
            res[i][i] = 1;
        }
        return res;
    } else if (n % 2 == 1) {
        matrix t = binpow(a, n / 2);
        return mult(a, mult(t, t));
    } else {
        matrix t = binpow(a, n / 2);
        return mult(t, t);
    }
}

int main() {
    int n,  x;
    map<int, int> d;
    matrix next = new_matrix();
    matrix init = new_matrix();
    matrix far;
    cin >> n >> x;

// init ni - map
    for ( int i = 0; i < n; i++ ){
        int di;
        cin >> di;
        d[di] += 1;
    }
// init matrix
    for( int i = 0; i < size-2; i++ )
        next[i][i+1] = 1;
    for ( int i = 0; i < size-1; i++ )
        next[size-2][size-1-i] = d[i];

    next[size-1][size-2] = 1;
    next[size-1][size-1] = 1;
// init

    init[size-2][0] = 1;
    far = mult ( binpow(next, x+1), init);
    cout << far[size-1][0] << endl;
  //  system("pause");
    return 0;
}


#include <iostream>
#include <map>

using namespace std;
const int size = 101;
const long long mod = 1e9+7;
typedef long long** matrix;

matrix new_matrix() {
    matrix res = new long long*[size];
    for (int i = 0; i < size; ++i) {
        res[i] = new long long[size];
        for (int j = 0; j < size; ++j) {
            res[i][j] = 0;
        }
    }
    return res;
}

matrix mult(matrix a, matrix b) {
    matrix res = new_matrix();
    for (int i = 0; i < size; ++i)
        for (int j = 0; j < size; ++j)
            for (int k = 0; k < size; ++k) {
                res[i][j] += a[i][k] * b[k][j];
                res[i][j] %= mod;
            }
    return res;
}

matrix binpow(matrix a, int n) {
    if (n == 0) {
        matrix res = new_matrix();
        for (int i = 0; i < size; ++i) {
            res[i][i] = 1;
        }
        return res;
    } else if (n % 2 == 1) {
        matrix t = binpow(a, n / 2);
        return mult(a, mult(t, t));
    } else {
        matrix t = binpow(a, n / 2);
        return mult(t, t);
    }
}

int main() {
    int n,  x;
    map<int, int> d;
    matrix next = new_matrix();
    matrix init = new_matrix();
    matrix far;
    cin >> n >> x;

// init ni - map
    for ( int i = 0; i < n; i++ ){
        int di;
        cin >> di;
        d[di] += 1;
    }
// init matrix
    for( int i = 0; i < size-2; i++ )
        next[i][i+1] = 1;
    for ( int i = 0; i < size; i++ )
        next[size-2][size-1-i] = d[i];

    next[size-1][size-2] = 1;
    next[size-1][size-1] = 1;
// init

    init[size-2][0] = 1;
    far = mult ( binpow(next, x+1), init);
    cout << far[size-1][0] << endl;
//   system("pause");
    return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<set>
using namespace std;
#define FOR(I,N) for(int(i)=0;i<int(N);++i)
typedef long long ll;
const int N = 1e5 + 5;
int n, x, a[N];
int f[101];
typedef vector<vector<int> > mat;
const int M = 1e9 + 7;
mat mul(mat &a,mat &b){
    mat ret;
    ret.resize(102);
    FOR(0, 102)
        ret[i].resize(102, 0);
    for (int k = 0; k < 102; ++k){
        for (int i = 0; i < 102; ++i){
            for (int j = 0; j < 102; ++j){
                ret[i][j] += (1ll * a[i][k] * b[k][j]) % M;
                ret[i][j] %= M;
            }
        }
    }
    return ret;
}
mat POW(mat &x, int rem){
    if (rem == 1)
        return x;
    mat r = POW(x, rem / 2);
    r = mul(r, r);
    if (rem & 1)
        r = mul(r, x);
    return r;
}
int main(){
    cin >> n >> x;
    if (!x){
        cout << 1 << endl;
        return 0;
    }
    mat dp;
    dp.resize(102);
    FOR(0, 102)
        dp[i].resize(102, 0);
    FOR(0, n){
        scanf("%d", &a[i]);
        ++f[a[i]];
    }
    for (int i = 0; i < 100; ++i){
        dp[i][i + 1] = 1;
        dp[i + 1][1] = f[i + 1];
        dp[i + 1][101] = f[i + 1];
    }
    dp[0][101] = 1;
    dp[101][101] = 1;
    mat res = POW(dp, x + 1);
    printf("%d\n", res[0][101]);
}


#include <bits/stdc++.h>
using namespace std;

#define IOS  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int  long long

#define rep(i,a,b) for(int i = a; i < b; i++)

const int N = 3e5 + 5;

vector<int> adj[N], cnt(N), vis(N);
vector<char> what(N);

void dfs(int src, char c) {
    vis[src] = 1;
    cnt[src] = what[src] == c;
    for(auto i : adj[src]) {
        if(vis[i] == 1) continue;
        dfs(i, c);
        cnt[src] = max(cnt[src], (what[src] == c ) + cnt[i]);
    }
}

int32_t main()
{
    IOS
    int n, m;
    cin >> n >> m;
    rep(i,0,n) {
        cin >> what[i];
    }
    vector<int> indeg(n);
    rep(i,0,m) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        indeg[y]++;
        adj[x].push_back(y);
    }
    queue<int> q;
    rep(i,0,n) {
        if(indeg[i] == 0) {
            q.push(i);
        }
    }
    int count = 0;
    while(!q.empty()) {
        int t = q.front();
        q.pop();
        count++;
        for(auto i : adj[t]) {
            indeg[i]--;
            if(indeg[i] == 0) {
                q.push(i);
            }
        }
    }
    if(count != n) {
        cout << -1 << endl;
        exit(0);
    }
    int ans = 0;
    for(char c = 'a'; c <= 'z'; c++) {
        rep(i,0,n) {
            if(vis[i]) continue;
            dfs(i, c);
        }
        rep(i,0,n) {
            ans = max(ans, cnt[i]);
            cnt[i] = vis[i] = 0;
        }
    }
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define IOS  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int  long long

#define rep(i,a,b) for(int i = a; i < b; i++)

const int N = 3e5 + 5;

vector<int> adj[N];
vector<int> cnt(N), vis(N);
vector<char> what(N);

void dfs(int src, char c) {
    cnt[src] = c == what[src];
    int mx = 0;
    vis[src] = 1;
    for(auto i : adj[src]) {
        if(vis[i]) continue;
        dfs(i, c);
        mx = max(mx, cnt[i]);
    }
    cnt[src] += mx;
}

int32_t main()
{
    IOS
    int n, m;
    cin >> n >> m;
    rep(i,0,n) {
        cin >> what[i];
    }
    vector<int> indeg(n);
    rep(i,0,m) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        indeg[y]++;
        adj[x].push_back(y);
    }
    queue<int> q;
    rep(i,0,n) {
        if(indeg[i] == 0) {
            q.push(i);
        }
    }
    int count = 0;
    while(!q.empty()) {
        int t = q.front();
        q.pop();
        count++;
        for(auto i : adj[t]) {
            indeg[i]--;
            if(indeg[i] == 0) {
                q.push(i);
            }
        }
    }
    if(count != n) {
        cout << -1 << endl;
        exit(0);
    }
    int ans = 0;
    for(char c = 'a'; c <= 'z'; c++) {
        rep(i,0,n) {
            if(vis[i]) continue;
            dfs(i, c);
        }
        rep(i,0,n) {
            ans = max(ans, cnt[i]);
            cnt[i] = 0;
            vis[i] = 0;
        }
    }
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

//#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
//int inf = 4e18;
const int N = 3e5+5;

string s;
int deg[N];
vector<int> adj[N];
int dp[N][26];
int n,m;

signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		cin>>n>>m;
		cin>>s;
		for(int i=0,u,v;i<m;++i)
		{
			cin>>u>>v;
			--u;--v;
			adj[u].pb(v);
			deg[v]++;
		}
		queue<int> q;
		for(int i=0;i<n;++i)
		{
			if(deg[i]==0)
			{
				q.push(i);
				dp[i][s[i]-'a']++;
			}
		}
		int ct = 0;
		while(!q.empty())
		{
			int frnt = q.front();
			q.pop();
			++ct;
			for(auto it:adj[frnt])
			{
				deg[it]--;
				if(deg[it]==0)
				{
					q.push(it);
				}
				int xxx = s[it]-'a';
				for(int i=0;i<26;++i)
				{
					if(xxx==i)
					{
						dp[it][i] = dp[frnt][i]+1;
					}
					else
					{
						dp[it][i] = dp[frnt][i];
					}
				}
			}
		}
		if(ct!=n)
		{
			cout<<-1;
			return 0;
		}
		int maxx = 0;
		for(int i=0;i<n;++i)
		{
			for(int j=0;j<26;++j)
			{
				maxx = max(maxx,dp[i][j]);
			}
		}
		cout<<maxx<<"\n";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

//#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
//int inf = 4e18;
const int N = 3e5+5;

string s;
int deg[N];
vector<int> adj[N];
int dp[N][26];
int n,m;

signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		cin>>n>>m;
		cin>>s;
		for(int i=0,u,v;i<m;++i)
		{
			cin>>u>>v;
			--u;--v;
			adj[u].pb(v);
			deg[v]++;
		}
		queue<int> q;
		for(int i=0;i<n;++i)
		{
			if(deg[i]==0)
			{
				q.push(i);
				dp[i][s[i]-'a']++;
			}
		}
		int ct = 0;
		while(!q.empty())
		{
			int frnt = q.front();
			q.pop();
			++ct;
			for(auto it:adj[frnt])
			{
				deg[it]--;
				if(deg[it]==0)
				{
					q.push(it);
				}
				int xxx = s[it]-'a';
				for(int i=0;i<26;++i)
				{
					if(xxx==i)
					{
						dp[it][i] = max(dp[frnt][i]+1,dp[it][i]);
					}
					else
					{
						dp[it][i] = max(dp[it][i],dp[frnt][i]);
					}
				}
			}
		}
		if(ct!=n)
		{
			cout<<-1;
			return 0;
		}
		int maxx = 0;
		for(int i=0;i<n;++i)
		{
			for(int j=0;j<26;++j)
			{
				maxx = max(maxx,dp[i][j]);
			}
		}
		cout<<maxx<<"\n";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 3e5+5;

string s;
int col[N];
int deg[N];
vector<int> adj[N];
int dp[N][26];
int n,m;

bool dfs(int child,int par)
{
	col[child] = 1;
	if(par==-1)
	dp[child][s[child]-'a']++;
	else
	{
		for(int i=0;i<26;++i)
		{
			dp[child][i]+= dp[par][i];
		}
		dp[child][s[child]-'a']++;
	}
	for(auto it:adj[child])
	{
		if(col[it]==0)
		{
			dfs(it,child);
		}
		if(col[it]==1)
		return true;
	}
	col[child] = 2;
	return false;
}

signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		cin>>n>>m;
		cin>>s;
		for(int i=0,u,v;i<m;++i)
		{
			cin>>u>>v;
			--u;--v;
			adj[u].pb(v);
			deg[v]++;
		}
		int ct  = 0;
		for(int i=0;i<n;++i)
		{
			if(deg[i]==0)
			{
				if(dfs(i,-1))
				{
					cout<<-1;
					return 0;
				}
				++ct;
			}
		}
		if(ct==0)
		{
			cout<<-1;
			return 0;
		}
		int maxx = 0;
		for(int i=0;i<n;++i)
		{
			for(int j=0;j<26;++j)
			{
				maxx = max(maxx,dp[i][j]);
			}
		}
		cout<<maxx<<"\n";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 3e5+5;

string s;
int col[N];
int deg[N];
vector<int> adj[N];
int dp[N][26];
int n,m;

bool dfs(int child,int par)
{
	col[child] = 1;
	if(par==-1)
	dp[child][s[child]-'a']++;
	else
	{
		for(int i=0;i<26;++i)
		{
			dp[child][i]+= dp[par][i];
		}
		dp[child][s[child]-'a']++;
	}
	for(auto it:adj[child])
	{
		if(col[it]==0)
		{
			dfs(it,child);
		}
		if(col[it]==1)
		return true;
	}
	col[child] = 2;
	return false;
}

signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		cin>>n>>m;
		cin>>s;
		for(int i=0,u,v;i<m;++i)
		{
			cin>>u>>v;
			--u;--v;
			adj[u].pb(v);
			deg[v]++;
		}
		for(int i=0;i<n;++i)
		{
			if(!col[i])
			{
				if(dfs(i,-1))
				{
					cout<<-1;
					return 0;
				}
			}
		}
		int maxx = 0;
		for(int i=0;i<n;++i)
		{
			for(int j=0;j<26;++j)
			{
				maxx = max(maxx,dp[i][j]);
			}
		}
		cout<<maxx<<"\n";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

//#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
//int inf = 4e18;
const int N = 3e5+5;

string s;
int deg[N];
vector<int> adj[N];
int dp[N][26];
int n,m;

signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		cin>>n>>m;
		cin>>s;
		for(int i=0,u,v;i<m;++i)
		{
			cin>>u>>v;
			--u;--v;
			adj[u].pb(v);
			deg[v]++;
		}
		queue<int> q;
		for(int i=0;i<n;++i)
		{
			if(deg[i]==0)
			{
				q.push(i);
				dp[i][s[i]-'a']++;
			}
		}
		int ct = 0,maxx = 0;
		while(!q.empty())
		{
			int frnt = q.front();
			q.pop();
			++ct;
			for(auto it:adj[frnt])
			{
				deg[it]--;
				if(deg[it]==0)
				{
					q.push(it);
				}
				int xxx = s[it]-'a';
				for(int i=0;i<26;++i)
				{
					dp[it][i] = max(dp[it][i],dp[frnt][i]+(xxx==i));
					maxx = max(maxx,dp[it][i]);
				}
			}
		}
		if(ct!=n)
		{
			cout<<-1;
			return 0;
		}
		cout<<maxx<<"\n";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 3e5+5;

string s;
int col[N];
int deg[N];
vector<int> adj[N];
int dp[N][26];
int n,m;

bool dfs(int child,int par)
{
	col[child] = 1;
	if(child==0)
	dp[child][s[child]-'a']++;
	else
	{
		for(int i=0;i<26;++i)
		{
			dp[child][i]+= dp[par][i];
		}
		dp[child][s[child]-'a']++;
	}
	for(auto it:adj[child])
	{
		if(col[it]==0)
		{
			dfs(it,child);
		}
		if(col[it]==1)
		return true;
	}
	col[child] = 2;
	return false;
}

signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		cin>>n>>m;
		cin>>s;
		for(int i=0,u,v;i<m;++i)
		{
			cin>>u>>v;
			--u;--v;
			adj[u].pb(v);
			deg[v]++;
		}
		if(dfs(0,-1))
		{
			cout<<-1;
			return 0;
		}
		int maxx = 0;
		for(int i=0;i<n;++i)
		{
			for(int j=0;j<26;++j)
			{
				maxx = max(maxx,dp[i][j]);
			}
		}
		cout<<maxx<<"\n";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define watch(x) cout << (#x) << " = " << (x) << endl
#define PI double(2 * acos(0.0))
#define LL long long
#define MOD 1000000007
#define all(x) (x).begin(), (x).end()
#define INF 1e15
vector<int> edges[300005];
int in[300005];
vector<int> v[300005];
map<pair<int, char>, int> mapi;
int main()  {
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n, m;
    cin >> n >> m;
    string s;
    cin >> s;
    int x, y;

    while(m--)  {
        cin >> x >> y;
        x--;
        y--;
        edges[x].push_back(y);
        v[y].push_back(x);
        in[y]++;
    }

    vector < int > ans;
    queue <int> q;
    int processed = 0;
    for(int i = 0; i < n; i++)    {
        if(!in[i])    {
            q.push(i);
            processed++;
        }
    }
    while(!q.empty())
    {
        int start = q.front();
        //cout << start << " ";
        for(auto i: v[start])   {
            for(int j = 0; j < 26; j++) {
                mapi[{start, (j+'a')}] = max(mapi[{start, j+'a'}], mapi[{i, j+'a'}]);
            }
        }
        mapi[{start, s[start]}]++;
        q.pop();
        for(auto i : edges[start])  {
            in[i] -= 1;
            if(in[i] == 0)        {
                q.push(i);
                processed++;
            }
        }
    }
    if(processed != n)  {
        cout << "-1";
        return 0;
    }
    int maxAns = 0;
    for(int i = 0; i < n; i++)  {
        for(int j = 0; j < 26; j++) {
            maxAns = max(maxAns, mapi[{i, j+'a'}]);
        }
    }
    cout << maxAns;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define watch(x) cout << (#x) << " = " << (x) << endl
#define PI double(2 * acos(0.0))
#define LL long long
#define MOD 1000000007
#define all(x) (x).begin(), (x).end()
#define INF 1e15
vector<int> edges[300005];
int in[300005];
vector<int> v[300005];
map<pair<int, int>, int> mapi;
int main()  {
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n, m;
    cin >> n >> m;
    string s;
    cin >> s;
    int x, y;

    while(m--)  {
        cin >> x >> y;
        x--;
        y--;
        edges[x].push_back(y);
        v[y].push_back(x);
        in[y]++;
    }

    vector < int > ans;
    queue <int> q;
    int processed = 0;
    for(int i = 0; i < n; i++)    {
        if(!in[i])    {
            q.push(i);
            processed++;
        }
    }
    while(!q.empty())
    {
        int start = q.front();
        //cout << start << " ";
        for(auto i: v[start])   {
            for(int j = 0; j < 26; j++) {
                mapi[{start, j}] = max(mapi[{start, j}], mapi[{i, j}]);
            }
        }
        mapi[{start, s[start] - 'a'}]++;
        q.pop();
        for(auto i : edges[start])  {
            in[i] -= 1;
            if(in[i] == 0)        {
                q.push(i);
                processed++;
            }
        }
    }
    if(processed != n)  {
        cout << "-1";
        return 0;
    }
    int maxAns = 0;
    for(int i = 0; i < n; i++)  {
        for(int j = 0; j < 26; j++) {
            maxAns = max(maxAns, mapi[{i, j}]);
        }
    }
    cout << maxAns;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define watch(x) cout << (#x) << " = " << (x) << endl
#define PI double(2 * acos(0.0))
#define LL long long
#define MOD 1000000007
#define all(x) (x).begin(), (x).end()
#define INF 1e15
vector<int> edges[300005];
int in[300005];
int dp[300005][26];
int main()  {
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n, m;
    cin >> n >> m;
    string s;
    cin >> s;
    int x, y;

    while(m--)  {
        cin >> x >> y;
        x--;
        y--;
        edges[x].push_back(y);
        in[y]++;
    }

    vector < int > ans;
    queue <int> q;
    int processed = 0;
    for(int i = 0; i < n; i++)    {
        if(!in[i])    {
            q.push(i);
            //mapi[{i, s[i] - 'a'}]++;
            processed++;
        }
    }
    while(!q.empty())
    {
        int start = q.front();
        //cout << start << " ";
        dp[start][s[start]-'a']++;
        q.pop();
        for(auto i : edges[start])  {
            for(int j = 0; j < 26; j++) {
                dp[i][j] = max(dp[i][j], dp[start][j]);
            }
            in[i] -= 1;
            if(in[i] == 0)        {
                q.push(i);
                processed++;
            }
        }
    }
    if(processed != n)  {
        cout << "-1";
        return 0;
    }
    int maxAns = 0;
    for(int i = 0; i < n; i++)  {
        for(int j = 0; j < 26; j++) {
            maxAns = max(maxAns, dp[i][j]);
        }
    }
    cout << maxAns;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define watch(x) cout << (#x) << " = " << (x) << endl
#define PI double(2 * acos(0.0))
#define LL long long
#define MOD 1000000007
#define all(x) (x).begin(), (x).end()
#define INF 1e15
vector<int> edges[300005];
int in[300005];
vector<int> v[300005];
map<pair<int, char>, int> mapi;
int main()  {
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n, m;
    cin >> n >> m;
    string s;
    cin >> s;
    int x, y;

    while(m--)  {
        cin >> x >> y;
        x--;
        y--;
        edges[x].push_back(y);
        v[y].push_back(x);
        in[y]++;
    }

    vector < int > ans;
    queue <int> q;
    int processed = 0;
    for(int i = 0; i < n; i++)    {
        if(!in[i])    {
            q.push(i);
            processed++;
        }
    }
    while(!q.empty())
    {
        int start = q.front();
        //cout << start << " ";
        for(auto i: v[start])   {
            for(int j = 0; j < 26; j++) {
                mapi[{start, (j+'a')}] = max(mapi[{start, j+'a'}], mapi[{i, j+'a'}]);
            }
        }
        v[start].clear();
        mapi[{start, s[start]}]++;
        q.pop();
        for(auto i : edges[start])  {
            in[i] -= 1;
            if(in[i] == 0)        {
                q.push(i);
                processed++;
            }
        }
        edges[start].clear();
    }
    if(processed != n)  {
        cout << "-1";
        return 0;
    }
    int maxAns = 0;
    for(int i = 0; i < n; i++)  {
        for(int j = 0; j < 26; j++) {
            maxAns = max(maxAns, mapi[{i, j+'a'}]);
        }
    }
    cout << maxAns;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define watch(x) cout << (#x) << " = " << (x) << endl
#define PI double(2 * acos(0.0))
#define LL long long
#define MOD 1000000007
#define all(x) (x).begin(), (x).end()
#define INF 1e15
vector<int> edges[300005];
int in[300005];
map<pair<int, char>, int> mapi;
int main()  {
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n, m;
    cin >> n >> m;
    string s;
    cin >> s;
    int x, y;

    while(m--)  {
        cin >> x >> y;
        x--;
        y--;
        edges[x].push_back(y);
        in[y]++;
    }

    vector < int > ans;
    queue <int> q;
    int processed = 0;
    for(int i = 0; i < n; i++)    {
        if(!in[i])    {
            q.push(i);
            //mapi[{i, s[i] - 'a'}]++;
            processed++;
        }
    }
    while(!q.empty())
    {
        int start = q.front();
        //cout << start << " ";
        mapi[{start, s[start]}]++;
        q.pop();
        for(auto i : edges[start])  {
            for(int j = 0; j < 26; j++) {
                mapi[{i, j+'a'}] = max(mapi[{i, j+'a'}], mapi[{start, j+'a'}]);
            }
            in[i] -= 1;
            if(in[i] == 0)        {
                q.push(i);
                processed++;
            }
        }
    }
    if(processed != n)  {
        cout << "-1";
        return 0;
    }
    int maxAns = 0;
    for(int i = 0; i < n; i++)  {
        for(int j = 0; j < 26; j++) {
            maxAns = max(maxAns, mapi[{i, j+'a'}]);
        }
    }
    cout << maxAns;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define watch(x) cout << (#x) << " = " << (x) << endl
#define PI double(2 * acos(0.0))
#define LL long long
#define MOD 1000000007
#define all(x) (x).begin(), (x).end()
#define INF 1e15
vector<int> edges[300005];
int in[300005];
vector<int> v[300005];
int main()  {
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n, m;
    cin >> n >> m;
    string s;
    cin >> s;
    int x, y;

    while(m--)  {
        cin >> x >> y;
        x--;
        y--;
        edges[x].push_back(y);
        v[y].push_back(x);
        in[y]++;
    }
    map<pair<int, int>, int> map;
    vector < int > ans;
    queue <int> q;
    int processed = 0;
    for(int i = 0; i < n; i++)    {
        if(!in[i])    {
            q.push(i);
            processed++;
        }
    }
    while(!q.empty())
    {
        int start = q.front();
        //cout << start << " ";
        for(auto i: v[start])   {
            for(int j = 0; j < 26; j++) {
                map[{start, j}] = max(map[{start, j}], map[{i, j}]);
            }
        }
        map[{start, s[start] - 'a'}]++;
        q.pop();
        for(auto i : edges[start])  {
            in[i] -= 1;
            if(in[i] == 0)        {
                q.push(i);
                processed++;
            }
        }
    }
    if(processed != n)  {
        cout << "-1";
        return 0;
    }
    int maxAns = 0;
    for(int i = 0; i < n; i++)  {
        for(int j = 0; j < 26; j++) {
            maxAns = max(maxAns, map[{i, j}]);
        }
    }
    cout << maxAns;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

#define         pb         push_back
#define         sf(x)      scanf("%d",&x)
#define         sfl(x)     scanf("%lld",&x)
#define         pf(x)      printf("%d\n",x)
#define         pfl(x)     printf("%lld\n",x)
#define         endl       '\n'
#define         pii        pair<int,int>
#define         mapii      map<int,int>
#define         mapll      map<ll,ll>
#define         mapci      map<char,int>
#define         mapcl      map<char,ll>
#define         mapsi      map<string,int>
#define         mapsl      map<string,ll>
#define         pll        pair<ll,ll>
#define         vi         vector<int>
#define         vl         vector<ll>
#define         vd         vector<double,double>
#define         all(c)     c.begin(),c.end()
#define         F          first
#define         S          second
#define         mp         make_pair
#define        ftc(x)      cerr << #x << ": " << x << " " << endl;
#define         PI         acos(-1)
#define         lcm(a,b)   ((a*b)/__gcd(a,b))
#define        optimize    ios_base::sync_with_stdio(false);cin.tie(NULL);
#define        sqr(a)       ((a)*(a))

#define   MAX 300009
int n,m;

string s;

int dp[MAX][30];

int vis[MAX];

vi ad[MAX];

void dfs(int x)
{
    vis[x] = 1;

  dp[x][s[x]-'a']++;

    for(int i = 0 ; i < ad[x].size(); i++)
    {
        int u = ad[x][i];

        if(vis[u] == 1)
        {
            cout << - 1 << endl;
            exit(0);
        }
        if(vis[u] == 0){
        dfs(u);

        for(int j = 0 ; j < 26;j++)
        {
            dp[x][j] += dp[u][j];
        }

        }
    }

    vis[x] = 2;
}

int main()
{
    int i,j,k,u,v;

    cin >> n >> m;

    cin >> s;

    s = '*' + s;

    for(i = 0 ; i< m ; i++)
    {
        cin >> u >> v;

        ad[u].pb(v);
    }

    for(i = 1 ; i <= n;i++)
    {
        if(!vis[i])
        {

            dfs(i);
        }
    }
    int ans = 0;

    for(i = 1 ; i <= n ;i++)
    {
        for(j = 0; j < 26 ;j++)
        ans = max(ans,dp[i][j]);
    }

    cout << ans << endl;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

#define         pb         push_back
#define         sf(x)      scanf("%d",&x)
#define         sfl(x)     scanf("%lld",&x)
#define         pf(x)      printf("%d\n",x)
#define         pfl(x)     printf("%lld\n",x)
#define         endl       '\n'
#define         pii        pair<int,int>
#define         mapii      map<int,int>
#define         mapll      map<ll,ll>
#define         mapci      map<char,int>
#define         mapcl      map<char,ll>
#define         mapsi      map<string,int>
#define         mapsl      map<string,ll>
#define         pll        pair<ll,ll>
#define         vi         vector<int>
#define         vl         vector<ll>
#define         vd         vector<double,double>
#define         all(c)     c.begin(),c.end()
#define         F          first
#define         S          second
#define         mp         make_pair
#define        ftc(x)      cerr << #x << ": " << x << " " << endl;
#define         PI         acos(-1)
#define         lcm(a,b)   ((a*b)/__gcd(a,b))
#define        optimize    ios_base::sync_with_stdio(false);cin.tie(NULL);
#define        sqr(a)       ((a)*(a))

#define   MAX 300009
int n,m;

string s;

int dp[MAX][30];

int vis[MAX];

vi ad[MAX];

void dfs(int x)
{
    vis[x] = 1;

    for(int i = 0 ; i < ad[x].size(); i++)
    {
        int u = ad[x][i];

        if(vis[u] == 1)
        {
            cout << - 1 << endl;
            exit(0);
        }
        if(vis[u] == 0){
        dp[u][s[u]-'a']++;

        for(int j = 0 ; j < 26;j++)
        {
            dp[u][j] += dp[x][j];
        }

        dfs(u);
        }
    }

    vis[x] = 2;
}

int main()
{
    int i,j,k,u,v;

    cin >> n >> m;

    cin >> s;

    s = '*' + s;

    for(i = 0 ; i< m ; i++)
    {
        cin >> u >> v;

        ad[u].pb(v);
    }

    for(i = 1 ; i <= n;i++)
    {
        if(!vis[i])
        {
            dp[i][s[i]-'a']++;

            dfs(i);
        }
    }
    int ans = 0;

    for(i = 1 ; i <= n ;i++)
    {
        for(j = 0; j < 26 ;j++)
        ans = max(ans,dp[i][j]);
    }

    cout << ans << endl;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

#define         pb         push_back
#define         sf(x)      scanf("%d",&x)
#define         sfl(x)     scanf("%lld",&x)
#define         pf(x)      printf("%d\n",x)
#define         pfl(x)     printf("%lld\n",x)
#define         endl       '\n'
#define         pii        pair<int,int>
#define         mapii      map<int,int>
#define         mapll      map<ll,ll>
#define         mapci      map<char,int>
#define         mapcl      map<char,ll>
#define         mapsi      map<string,int>
#define         mapsl      map<string,ll>
#define         pll        pair<ll,ll>
#define         vi         vector<int>
#define         vl         vector<ll>
#define         vd         vector<double,double>
#define         all(c)     c.begin(),c.end()
#define         F          first
#define         S          second
#define         mp         make_pair
#define        ftc(x)      cerr << #x << ": " << x << " " << endl;
#define         PI         acos(-1)
#define         lcm(a,b)   ((a*b)/__gcd(a,b))
#define        optimize    ios_base::sync_with_stdio(false);cin.tie(NULL);
#define        sqr(a)       ((a)*(a))

#define   MAX 300009
int n,m;

string s;

int dp[MAX][30];

int vis[MAX];

vi ad[MAX];

void dfs(int x)
{
    vis[x] = 1;

    for(int i = 0 ; i < ad[x].size(); i++)
    {
        int u = ad[x][i];

        if(vis[u] == 1)
        {
            cout << - 1 << endl;
            exit(0);
        }
        if(vis[u] == 0)
        {

            dfs(u);

            for(int j = 0 ; j < 26 ; j++)
            {
               dp[x][j] = max(dp[x][j],dp[u][j]);
            }
        }
    }

    dp[x][s[x]-'a']++;

    vis[x] = 2;
}

int main()
{
    int i,j,k,u,v;

    cin >> n >> m;

    cin >> s;

    s = '*' + s;

    for(i = 0 ; i< m ; i++)
    {
        cin >> u >> v;

        ad[u].pb(v);
    }

    for(i = 1 ; i <= n; i++)
    {
        if(!vis[i])
        {

            dfs(i);
        }
    }
    int ans = 0;

    for(i = 1 ; i <= n ; i++)
    {
        for(j = 0; j < 26 ; j++)
            ans = max(ans,dp[i][j]);
    }

    cout << ans << endl;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

#define         pb         push_back
#define         sf(x)      scanf("%d",&x)
#define         sfl(x)     scanf("%lld",&x)
#define         pf(x)      printf("%d\n",x)
#define         pfl(x)     printf("%lld\n",x)
#define         endl       '\n'
#define         pii        pair<int,int>
#define         mapii      map<int,int>
#define         mapll      map<ll,ll>
#define         mapci      map<char,int>
#define         mapcl      map<char,ll>
#define         mapsi      map<string,int>
#define         mapsl      map<string,ll>
#define         pll        pair<ll,ll>
#define         vi         vector<int>
#define         vl         vector<ll>
#define         vd         vector<double,double>
#define         all(c)     c.begin(),c.end()
#define         F          first
#define         S          second
#define         mp         make_pair
#define        ftc(x)      cerr << #x << ": " << x << " " << endl;
#define         PI         acos(-1)
#define         lcm(a,b)   ((a*b)/__gcd(a,b))
#define        optimize    ios_base::sync_with_stdio(false);cin.tie(NULL);
#define        sqr(a)       ((a)*(a))

#define   MAX 300009
int n,m;

string s;

int dp[MAX][30];

int vis[MAX];

vi ad[MAX];

void dfs(int x)
{
    vis[x] = 1;
dp[x][s[x]-'a']++;
    for(int i = 0 ; i < ad[x].size(); i++)
    {
        int u = ad[x][i];

        if(vis[u] == 1)
        {
            cout << - 1 << endl;
            exit(0);
        }
        if(vis[u] == 0){

        for(int j = 0 ;j < 26 ; j++)
        {
            dp[u][j] = max(dp[u][j],dp[u][j]+dp[x][j]);
        }
        dfs(u);
        }
    }

    vis[x] = 2;
}

int main()
{
    int i,j,k,u,v;

    cin >> n >> m;

    cin >> s;

    s = '*' + s;

    for(i = 0 ; i< m ; i++)
    {
        cin >> u >> v;

        ad[u].pb(v);
    }

    for(i = 1 ; i <= n;i++)
    {
        if(!vis[i])
        {

            dfs(i);
        }
    }
    int ans = 0;

    for(i = 1 ; i <= n ;i++)
    {
        for(j = 0; j < 26 ;j++)
        ans = max(ans,dp[i][j]);
    }

    cout << ans << endl;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

#define         pb         push_back
#define         sf(x)      scanf("%d",&x)
#define         sfl(x)     scanf("%lld",&x)
#define         pf(x)      printf("%d\n",x)
#define         pfl(x)     printf("%lld\n",x)
#define         endl       '\n'
#define         pii        pair<int,int>
#define         mapii      map<int,int>
#define         mapll      map<ll,ll>
#define         mapci      map<char,int>
#define         mapcl      map<char,ll>
#define         mapsi      map<string,int>
#define         mapsl      map<string,ll>
#define         pll        pair<ll,ll>
#define         vi         vector<int>
#define         vl         vector<ll>
#define         vd         vector<double,double>
#define         all(c)     c.begin(),c.end()
#define         F          first
#define         S          second
#define         mp         make_pair
#define        ftc(x)      cerr << #x << ": " << x << " " << endl;
#define         PI         acos(-1)
#define         lcm(a,b)   ((a*b)/__gcd(a,b))
#define        optimize    ios_base::sync_with_stdio(false);cin.tie(NULL);
#define        sqr(a)       ((a)*(a))

#define   MAX 300009
int n,m;

string s;

int dp[MAX][30];

int vis[MAX];

vi ad[MAX];

int ans = 0;
void dfs(int x)
{
    vis[x] = 1;

    for(int i = 0 ; i < ad[x].size(); i++)
    {
        int u = ad[x][i];

        if(vis[u] == 1)
        {
            cout << - 1 << endl;
            exit(0);
        }
        if(vis[u] == 0)
        {

            dfs(u);

            for(int j = 0 ; j < 26 ; j++)
            {
               dp[x][j] = max(dp[x][j],dp[u][j]);
            }
        }
    }

    dp[x][s[x]-'a']++;

     for(int i=0;i<26;i++)
    {
        ans=max(ans,dp[x][i]);
    }

    vis[x] = 2;
}

int main()
{
    int i,j,k,u,v;

    cin >> n >> m;

    cin >> s;

    s = '*' + s;

    for(i = 0 ; i< m ; i++)
    {
        cin >> u >> v;

        ad[u].pb(v);
    }

    for(i = 1 ; i <= n; i++)
    {
        if(!vis[i])
        {

            dfs(i);
        }
    }

    cout << ans << endl;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

#define         pb         push_back
#define         sf(x)      scanf("%d",&x)
#define         sfl(x)     scanf("%lld",&x)
#define         pf(x)      printf("%d\n",x)
#define         pfl(x)     printf("%lld\n",x)
#define         endl       '\n'
#define         pii        pair<int,int>
#define         mapii      map<int,int>
#define         mapll      map<ll,ll>
#define         mapci      map<char,int>
#define         mapcl      map<char,ll>
#define         mapsi      map<string,int>
#define         mapsl      map<string,ll>
#define         pll        pair<ll,ll>
#define         vi         vector<int>
#define         vl         vector<ll>
#define         vd         vector<double,double>
#define         all(c)     c.begin(),c.end()
#define         F          first
#define         S          second
#define         mp         make_pair
#define        ftc(x)      cerr << #x << ": " << x << " " << endl;
#define         PI         acos(-1)
#define         lcm(a,b)   ((a*b)/__gcd(a,b))
#define        optimize    ios_base::sync_with_stdio(false);cin.tie(NULL);
#define        sqr(a)       ((a)*(a))

#define   MAX 300009
int n,m;

string s;

int dp[MAX][30];

int vis[MAX];

vi ad[MAX];

int ans = 0;
void dfs(int x)
{
    vis[x] = 1;

    for(int i = 0 ; i < ad[x].size(); i++)
    {
        int u = ad[x][i];

        if(vis[u] == 1)
        {
            cout << - 1 << endl;
            exit(0);
        }
          if(vis[u] == 0)
            dfs(u);

            for(int j = 0 ; j < 26 ; j++)
            {
               dp[x][j] = max(dp[x][j],dp[u][j]);
            }

    }

    dp[x][s[x]-'a']++;

     for(int i=0;i<26;i++)
    {
        ans=max(ans,dp[x][i]);
    }

    vis[x] = 2;
}

int main()
{
    int i,j,k,u,v;

    cin >> n >> m;

    cin >> s;

    s = '*' + s;

    for(i = 0 ; i< m ; i++)
    {
        cin >> u >> v;

        ad[u].pb(v);
    }

    for(i = 1 ; i <= n; i++)
    {
        if(!vis[i])
        {

            dfs(i);
        }
    }

    cout << ans << endl;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

#define         pb         push_back
#define         sf(x)      scanf("%d",&x)
#define         sfl(x)     scanf("%lld",&x)
#define         pf(x)      printf("%d\n",x)
#define         pfl(x)     printf("%lld\n",x)
#define         endl       '\n'
#define         pii        pair<int,int>
#define         mapii      map<int,int>
#define         mapll      map<ll,ll>
#define         mapci      map<char,int>
#define         mapcl      map<char,ll>
#define         mapsi      map<string,int>
#define         mapsl      map<string,ll>
#define         pll        pair<ll,ll>
#define         vi         vector<int>
#define         vl         vector<ll>
#define         vd         vector<double,double>
#define         all(c)     c.begin(),c.end()
#define         F          first
#define         S          second
#define         mp         make_pair
#define        ftc(x)      cerr << #x << ": " << x << " " << endl;
#define         PI         acos(-1)
#define         lcm(a,b)   ((a*b)/__gcd(a,b))
#define        optimize    ios_base::sync_with_stdio(false);cin.tie(NULL);
#define        sqr(a)       ((a)*(a))

int n,m;

string s;

int dp[3000009][30];

int vis[3000009];

vi ad[3000009];

void dfs(int x)
{
    vis[x] = 1;

    for(int i = 0 ; i < ad[x].size(); i++)
    {
        int u = ad[x][i];

        if(vis[u] == 1)
        {
            cout << - 1 << endl;
            exit(0);
        }
        if(vis[u] == 0){
        dp[u][s[u]-'a']++;

        for(int j = 0 ; j < 26;j++)
        {
            dp[u][j] += dp[x][j];
        }

        dfs(u);
        }
    }

    vis[x] = 2;
}

int main()
{
    int i,j,k,u,v;

    cin >> n >> m;

    cin >> s;

    s = '*' + s;

    for(i = 0 ; i< m ; i++)
    {
        cin >> u >> v;

        ad[u].pb(v);
    }

    for(i = 1 ; i <= n;i++)
    {
        if(!vis[i])
        {
            dp[i][s[i]-'a']++;

            dfs(i);
        }
    }
    int ans = 0;

    for(i = 1 ; i <= n ;i++)
    {
        for(j = 0; j < 26 ;j++)
        ans = max(ans,dp[i][j]);
    }

    cout << ans << endl;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

#define         pb         push_back
#define         sf(x)      scanf("%d",&x)
#define         sfl(x)     scanf("%lld",&x)
#define         pf(x)      printf("%d\n",x)
#define         pfl(x)     printf("%lld\n",x)
#define         endl       '\n'
#define         pii        pair<int,int>
#define         mapii      map<int,int>
#define         mapll      map<ll,ll>
#define         mapci      map<char,int>
#define         mapcl      map<char,ll>
#define         mapsi      map<string,int>
#define         mapsl      map<string,ll>
#define         pll        pair<ll,ll>
#define         vi         vector<int>
#define         vl         vector<ll>
#define         vd         vector<double,double>
#define         all(c)     c.begin(),c.end()
#define         F          first
#define         S          second
#define         mp         make_pair
#define        ftc(x)      cerr << #x << ": " << x << " " << endl;
#define         PI         acos(-1)
#define         lcm(a,b)   ((a*b)/__gcd(a,b))
#define        optimize    ios_base::sync_with_stdio(false);cin.tie(NULL);
#define        sqr(a)       ((a)*(a))

#define   MAX 300009
int n,m;

string s;

int dp[MAX][30];

int vis[MAX];

vi ad[MAX];

int ans = 0;
void dfs(int x)
{
    vis[x] = 1;

    for(int i = 0 ; i < ad[x].size(); i++)
    {
        int u = ad[x][i];

         if(vis[u] == 0)
        {

            dfs(u);
        }
        if(vis[u] == 1)
        {
            cout << - 1 << endl;
            exit(0);
        }

            for(int j = 0 ; j < 26 ; j++)
            {
               dp[x][j] = max(dp[x][j],dp[u][j]);
            }

    }

    dp[x][s[x]-'a']++;

     for(int i=0;i<26;i++)
    {
        ans=max(ans,dp[x][i]);
    }

    vis[x] = 2;
}

int main()
{
    int i,j,k,u,v;

    cin >> n >> m;

    cin >> s;

    s = '*' + s;

    for(i = 0 ; i< m ; i++)
    {
        cin >> u >> v;

        ad[u].pb(v);
    }

    for(i = 1 ; i <= n; i++)
    {
        if(!vis[i])
        {

            dfs(i);
        }
    }

    cout << ans << endl;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
ll maxN=1;
string s;
vector<set<ll>>v;
vector<ll>map1(26, 0);
//map<char, int>map1;
vector<bool>visited;
bool dfs(ll pos){
  if(v[pos].size()==0){
    return true;
  }

  ll i, j, k;

  for(auto l:v[pos]){
    if(visited[l]){
      return false;
    }
    visited[l]=true;
    auto z=++map1[s[l-1]-'a'];
    if(z>maxN)
      maxN=z;
    auto ans=dfs(l);
    visited[l]=false;
    map1[s[l-1]-'a']--;
    if(!ans)
      return false;
  }
  return true;
}
int main()
{
  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  ll i, j, k, n, a, b, m;
  cin>>n>>m;

  v=vector<set<ll>>(n+1);
  visited=vector<bool>(n+1, false);
  cin>>s;
  // for(i=1; i<=n; i++)
  //   v[i].insert(i);
  for(i=0; i<m; i++){
    cin>>a>>b;
    v[a].insert(b);
  }
  for(i=1; i<=n; i++){
    visited[i]=true;
   int c=s[(i-1)]-'a';
    map1[c]++;
    auto ans=dfs(i);
    map1[c]--;
    visited[i]=false;
    if(!ans){
      cout<<-1;
      return 0;
    }
  }
  cout<<maxN;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
ll maxN=1;
string s;
vector<set<ll>>v;
map<char, int>map1;
vector<bool>visited;
bool dfs(ll pos, ll num){
  if(v[pos].size()==1){
    return true;
  }
  if(num!=0&&v[pos].size()==1){
    return true;
  }
  ll i, j, k, count=0;
  for(auto l:v[pos]){
    if(visited[l]&& l!=pos){
      return false;
    }
    if(!visited[l]){
      count++;
      visited[l]=true;
      auto z=++map1[s[pos-1]];
      if(z>maxN)
        maxN=z;
      auto ans=dfs(l, num+1);
      visited[l]=false;
      map1[s[pos-1]]--;
      if(!ans)
        return false;
    }
  }
  return true;
}
int main()
{
  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  ll i, j, k, n, a, b, m;
  cin>>n>>m;

  v=vector<set<ll>>(n+1);
  visited=vector<bool>(n+1, false);
  cin>>s;
  for(i=1; i<=n; i++)
    v[i].insert(i);
  for(i=0; i<m; i++){
    cin>>a>>b;
    v[a].insert(b);
  }
  for(i=1; i<=n; i++){
    visited[i]=true;
    char c=s[(i-1)];
    map1[c]++;
    auto ans=dfs(i, 0);
    map1[c]--;
    visited[i]=false;
    if(!ans){
      cout<<-1;
      return 0;
    }
  }
  cout<<maxN;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
ll maxN=1;
string s;
vector<set<ll>>v;
vector<vector<ll>>map1;
//map<char, int>map1;
vector<bool>visited, calculated;
bool dfs(ll pos){
  if(calculated[pos]){
    return true;
  }
  calculated[pos]=true;
  if(v[pos].size()==0){
    map1[pos][s[pos-1]-'a']=1;
    return true;
  }

  ll i, j, k;

  for(auto l:v[pos]){
    if(visited[l]){
      return false;
    }
    visited[l]=true;
    //auto z=++map1[s[l-1]-'a'];

    auto ans=dfs(l);
    if(!ans)
      return false;
    map1[pos][s[pos-1]-'a']=max(map1[l][s[pos-1]-'a']+1, map1[pos][s[pos-1]-'a']);
    for(i=0; i<26; i++){
      map1[pos][i]=max(map1[l][i], map1[pos][i]);
      if(map1[pos][i]>maxN)
        maxN=map1[pos][i];
    }

    if(map1[pos][s[pos-1]-'a']>maxN)
        maxN=map1[pos][s[pos-1]-'a'];
    visited[l]=false;
  }
  return true;
}
int main()
{
  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  ll i, j, k, n, a, b, m;
  cin>>n>>m;

  v=vector<set<ll>>(n+1);
  visited=vector<bool>(n+1, false);
  calculated=vector<bool>(n+1, false);
  map1=vector<vector<ll>>(n+1, vector<ll>(26,0));
  cin>>s;
  // for(i=1; i<=n; i++)
  //   v[i].insert(i);
  for(i=0; i<m; i++){
    cin>>a>>b;
    v[a].insert(b);
  }
  for(i=1; i<=n; i++){
    visited[i]=true;
   int c=s[(i-1)]-'a';
    map1[i][c]++;
    auto ans=dfs(i);
    map1[i][c]--;
    visited[i]=false;
    if(!ans){
      cout<<-1;
      return 0;
    }
  }
  cout<<maxN;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
ll maxN=1;
string s;
vector<set<ll>>v;
map<char, int>map1;
vector<bool>visited;
bool dfs(ll pos, ll num){
  if(v[pos].size()==0){
    return true;
  }
  // if(num!=0&&v[pos].size()==0){
  //   return true;
  // }
  ll i, j, k, count=0;
  for(auto l:v[pos]){
    if(visited[l]){
      return false;
    }
    if(!visited[l]){
      count++;
      visited[l]=true;
      auto z=++map1[s[pos-1]];
      if(z>maxN)
        maxN=z;
      auto ans=dfs(l, num+1);
      visited[l]=false;
      map1[s[pos-1]]--;
      if(!ans)
        return false;
    }
  }
  return true;
}
int main()
{
  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  ll i, j, k, n, a, b, m;
  cin>>n>>m;

  v=vector<set<ll>>(n+1);
  visited=vector<bool>(n+1, false);
  cin>>s;
  // for(i=1; i<=n; i++)
  //   v[i].insert(i);
  for(i=0; i<m; i++){
    cin>>a>>b;
    v[a].insert(b);
  }
  for(i=1; i<=n; i++){
    visited[i]=true;
    char c=s[(i-1)];
    map1[c]++;
    auto ans=dfs(i, 0);
    map1[c]--;
    visited[i]=false;
    if(!ans){
      cout<<-1;
      return 0;
    }
  }
  cout<<maxN;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
ll maxN=1;
string s;
vector<set<ll>>v;
vector<vector<ll>>map1;
//map<char, int>map1;
vector<bool>visited, calculated;
bool dfs(ll pos){
  if(calculated[pos]){
    return true;
  }
  calculated[pos]=true;
  if(v[pos].size()==0){
    map1[pos][s[pos-1]-'a']=1;
    return true;
  }

  ll i, j, k;

  for(auto l:v[pos]){
    if(visited[l]){
      return false;
    }
    visited[l]=true;

    auto ans=dfs(l);
    if(!ans)
      return false;
    map1[pos][s[pos-1]-'a']=max(map1[l][s[pos-1]-'a']+1, map1[pos][s[pos-1]-'a']);
    for(i=0; i<26; i++){
      map1[pos][i]=max(map1[l][i], map1[pos][i]);
      if(map1[pos][i]>maxN)
        maxN=map1[pos][i];
    }

    if(map1[pos][s[pos-1]-'a']>maxN)
        maxN=map1[pos][s[pos-1]-'a'];
    visited[l]=false;
  }
  return true;
}
int main()
{
  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  ll i, j, k, n, a, b, m;
  cin>>n>>m;

  v=vector<set<ll>>(n+1);
  visited=vector<bool>(n+1, false);
  calculated=vector<bool>(n+1, false);
  map1=vector<vector<ll>>(n+1, vector<ll>(26,0));
  cin>>s;

  for(i=0; i<m; i++){
    cin>>a>>b;
    v[a].insert(b);
  }
  for(i=1; i<=n; i++){
    visited[i]=true;
   int c=s[(i-1)]-'a';
    //map1[i][c]++;
    auto ans=dfs(i);
    //map1[i][c]--;
    visited[i]=false;
    if(!ans){
      cout<<-1;
      return 0;
    }
  }
  cout<<maxN;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
ll maxN=1;
string s;
vector<set<ll>>v;
map<char, int>map1;
vector<bool>visited;
bool dfs(ll pos){
  if(v[pos].size()==0){
    return true;
  }

  ll i, j, k;

  for(auto l:v[pos]){
    if(visited[l]){
      return false;
    }
    visited[l]=true;
    auto z=++map1[s[l-1]];
    if(z>maxN)
      maxN=z;
    auto ans=dfs(l);
    visited[l]=false;
    map1[s[l-1]]--;
    if(!ans)
      return false;
  }
  return true;
}
int main()
{
  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  ll i, j, k, n, a, b, m;
  cin>>n>>m;

  v=vector<set<ll>>(n+1);
  visited=vector<bool>(n+1, false);
  cin>>s;
  // for(i=1; i<=n; i++)
  //   v[i].insert(i);
  for(i=0; i<m; i++){
    cin>>a>>b;
    v[a].insert(b);
  }
  for(i=1; i<=n; i++){
    visited[i]=true;
    char c=s[(i-1)];
    map1[c]++;
    auto ans=dfs(i);
    map1[c]--;
    visited[i]=false;
    if(!ans){
      cout<<-1;
      return 0;
    }
  }
  cout<<maxN;
  return 0;
}