#include<bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define ini(x, y) memset(x, y, sizeof(x));
#define pb push_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = (int)1e9 + 7;
const int MAX = (int)2e9;
const double PI = acos(-1);

int prime[1001];
vector<int> P;
int l, r;
ll sol(vector<int>& fac, int i) {
	ll res = 0;
	for (int sub = (1 << sz(fac)) - 1; sub; sub = (sub - 1) & (1 << (sz(fac))) - 1) {
		int val = 1;
		int cnt = 0;
		for (int j = 0; j < sz(fac); j++) {
			if ((1 << j) & sub) {
				val *= fac[j];
				cnt++;
			}
		}
		if (val != 1) {
			int k = r / val - i / val;
			if (cnt % 2) res += k;
			else res -= k;
		}
	}
	return res;
}
int main(void) {
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	//freopen("input.txt", "r", stdin);
	for (int i = 2; i <= 1000; i++) {
		if (prime[i] == 0) {
			P.pb(i);
			for (int j = 2; j * i <= 1000; j++) {
				prime[i * j] = 1;
			}
		}
	}
	ll ans = 0;
	 cin >> l >> r;
	for (int i = max(2, l); i < r; i++) {
		int k = i;
		vector<int> fac;
		int idx = 0;
		for (int i = 0; i < sz(P); i++) {
			if (k == 1) break;
			if (k % P[i] == 0) {
				fac.pb(P[i]);
				while (k % P[i] == 0) k /= P[i];
			}
		}
		if (k > 1) fac.pb(k);
		ans += sol(fac, i);
		ans -= r / i - 1;
	}
	cout << ans*2;
}
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;


int main()
{ios_base::sync_with_stdio(false);
cin.tie(0);
int n,k;
cin>>n>>k;
vll c(n+5,0);
rep(i,0,n-1)
{
	int x;
	cin>>x;
	c[x]++;
}

ll cnt=min(c[0],1ll*k);
ll ans=cnt;
rep(i,1,n)
{
	cnt=min(cnt,c[i]);
	ans+=cnt;
}
ol(ans);
return 0;
}



