#include <stdio.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <string.h>
#define LL long long
#define _LL __int64

using namespace std;

map < pair<int, int>, int > mp;
int n,p;
int cnt1[300010],cnt2[300010];
int a,b;
int ans;
int main()
{
    int i,j;
    while(~scanf("%d %d",&n,&p))
    {
        mp.clear();
        memset(cnt1,0,sizeof(cnt1));
        memset(cnt2,0,sizeof(cnt2));

        for(i = 1; i <= n; i++)
        {
            scanf("%d %d",&a,&b);
            mp[ make_pair(min(a,b),max(a,b)) ]++;
            cnt1[a]++;
            cnt1[b]++;
            cnt2[a]++;
            cnt2[b]++;
        }

        LL ans = 0;
        sort(cnt1+1,cnt1+1+n);

        for(int i = 1; i <= n; i++)
        {
            int add = lower_bound(cnt1+1+i, cnt1+1+n, p-cnt1[i])-cnt1;
            ans += max(0,n+1-add);
        }

        map< pair<int, int>, int>::iterator it;
        for(it = mp.begin(); it != mp.end(); it++)
        {
            a = it->first.first;
            b = it->first.second;

            if( cnt2[a] + cnt2[b] >= p && (cnt2[a] + cnt2[b] - mp[make_pair(a,b)] < p) )
                ans--;
        }
        printf("%LLd\n",ans);
    }
    return 0;

}


#include <stdio.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <string.h>
using namespace std;

map < pair<int, int>, int > mp;
int n,p;
int cnt1[300010],cnt2[300010];
int a,b;
int ans;
int main()
{
    int i,j;
    while(~scanf("%d %d",&n,&p))
    {
        mp.clear();
        memset(cnt1,0,sizeof(cnt1));
        memset(cnt2,0,sizeof(cnt2));

        for(i = 1; i <= n; i++)
        {
            scanf("%d %d",&a,&b);
            mp[ make_pair(a,b) ]++;
            cnt1[a]++;
            cnt1[b]++;
            cnt2[a]++;
            cnt2[b]++;
        }

        ans = 0;
        sort(cnt1+1,cnt1+1+n);

        for(i = 1; i < n; i++)
        {
            for(j = i+1; j <= n; j++)
            {
                if(cnt1[i] + cnt1[j] >= p)
                    break;
            }
            ans += n+1-j;
        }

        map< pair<int, int>, int> :: iterator it;
        for(it = mp.begin(); it != mp.end(); it++)
        {
            a = it->first.first;
            b = it->first.second;

            if( cnt2[a] + cnt2[b] >= p && (cnt2[a] + cnt2[b]- (it->second) < p) )
                ans--;
        }
        printf("%d\n",ans);
    }
    return 0;

}


#include <stdio.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <string.h>
#define LL long long
#define _LL __int64

using namespace std;
const int INF = 0x3f3f3f3f;

map < pair<int, int>, int > mp;
int n,p;
int c1[300010],c2[300010];
_LL ans;

int main()
{
    int i,j,a,b;
    scanf("%d %d",&n,&p);
    memset(c1,0,sizeof(c1));
    memset(c2,0,sizeof(c2));

    for(i = 1; i <= n; i++)
    {
        scanf("%d %d",&a,&b);
        if(a > b)
            swap(a,b);

        c1[a]++;
        c1[b]++;
        c2[a]++;
        c2[b]++;

        mp[ make_pair(a,b) ] += 1;
    }

    sort(c1+1,c1+1+n);
    map< pair<int,int>,int>::iterator it;
    ans = 0;
    for(i = 1; i <= n; i++)
    {
        int add = lower_bound(c1+1+i,c1+1+n,p-c1[i]) - c1;
        ans += n+1-add;
    }

    for(it = mp.begin(); it != mp.end(); it++)
    {
        a = it->first.first;
        b = it->first.second;
        if(c2[a]+ c2[b] >= p && c2[a] + c2[b] - mp[make_pair(a,b)] < p)
        {
            ans--;
        }
    }
    printf("%I64d\n",ans);
    return 0;
}


#include <stdio.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <string.h>
#define LL long long
#define _LL __int64

using namespace std;
const int INF = 0x3f3f3f3f;

map < pair<int, int>, int > mp;
int n,p;
int c1[300010],c2[300010];
_LL ans;

int main()
{
    int i,j,a,b;
    scanf("%d %d",&n,&p);
    memset(c1,0,sizeof(c1));
    memset(c2,0,sizeof(c2));

    for(i = 1; i <= n; i++)
    {
        scanf("%d %d",&a,&b);
        if(a > b)
            swap(a,b);

        c1[a]++;
        c1[b]++;
        c2[a]++;
        c2[b]++;

        mp[ make_pair(a,b) ] += 1;
    }

    sort(c1+1,c1+1+n);
    map< pair<int,int>,int>::iterator it;
    ans = 0;
    for(i = 1; i <= n; i++)
    {
        int add = lower_bound(c1+1+i,c1+1+n,p-c1[i]) - c1;
        ans += n+1-add;
    }

    for(it = mp.begin(); it != mp.end(); it++)
    {
        a = it->first.first;
        b = it->first.second;
        if(c2[a]+ c2[b] >= p)
        {
            if(c2[a] + c2[b] - mp[make_pair(a,b)] < p)
                ans--;
        }
    }
    printf("%I64d\n",ans);
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <set>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

struct node{
    int x;
    int y;
    void change(){
        int c;
        if(x>y){
            c=x;x=y;y=c;
        }
    }
    bool operator <(const node &a)const{
        if(x<a.x||x==a.x&&y<a.y)return 1;
        return 0;
    }
}que[310000];
map<node,int>mp;
int num[310000];
int z[310000];
int n,m,p;
int lower(int x){
    int l=1,r=n;
    int mid;
    while(l<=r){
        mid=(l+r)>>1;
        if(num[mid]>=x)r=mid-1;
        else l=mid+1;
    }
    return n-l+1;
}
int main()
{
    cin>>n>>p;
    node x;
    int a,b;
    for(int i=0;i<n;i++){
        scanf("%d%d",&que[i].x,&que[i].y);
        que[i].change();
        if(mp.find(que[i])!=mp.end())mp[que[i]]++;
        else{
            mp[que[i]]=1;
        }
        num[que[i].x]++,num[que[i].y]++;
    }
    int ans=0;
    for(int i=1;i<=n;i++)z[i]=num[i];
    sort(num+1,num+n+1);
    for(int i=1;i<=n;i++){
                ans+=lower(p-num[i]);
        if(num[i]*2>=p)ans-=1;
    }
    for(int i=0;i<n;i++){
        if(mp[que[i]]!=-1&&z[que[i].x]+z[que[i].y]>=p&&p>z[que[i].x]+z[que[i].y]-mp[que[i]]){
            ans-=2;
            //cout<<i<<" "<<mp[que[i]]<<" "<<que[i].x<<"   "<<que[i].y<<endl;
        }

        mp[que[i]]=-1;
    }
    printf("%d\n",ans/2);
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <set>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

struct node{
    int x;
    int y;
    void change(){
        int c;
        if(x>y){
            c=x;x=y;y=c;
        }
    }
    bool operator <(const node &a)const{
        if(x<a.x||x==a.x&&y<a.y)return 1;
        return 0;
    }
}que[310000];
map<node,int>mp;
int num[310000];
int n,m,p;
int lower(int x){
    int l=1,r=n;
    int mid;
    while(l<=r){
        mid=(l+r)>>1;
        if(num[mid]>=x)r=mid-1;
        else l=mid+1;
    }
    return n-l+1;
}
int main()
{
    cin>>n>>p;
    node x;
    int a,b;
    for(int i=0;i<n;i++){
        scanf("%d%d",&que[i].x,&que[i].y);
        que[i].change();
        if(mp.find(que[i])!=mp.end())mp[que[i]]++;
        else{
            mp[que[i]]=1;
        }
        num[que[i].x]++,num[que[i].y]++;
    }
    int ans=0;
    sort(num+1,num+n+1);
    for(int i=1;i<=n;i++){
                ans+=lower(p-num[i]);
        if(num[i]*2>=p)ans-=1;
    }
    for(int i=0;i<n;i++){
        if(mp[que[i]]!=-1&&num[que[i].x]+num[que[i].y]>=p&&p>num[que[i].x]+num[que[i].y]-mp[que[i]]){
            ans-=2;
            cout<<i<<" "<<mp[que[i]]<<" "<<que[i].x<<"   "<<que[i].y<<endl;
        }

        mp[que[i]]=-1;
    }
    printf("%d\n",ans/2);
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <set>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

struct node{
    int x;
    int y;
    void change(){
        int c;
        if(x>y){
            c=x;x=y;y=c;
        }
    }
    bool operator <(const node &a)const{
        if(x<a.x||x==a.x&&y<a.y)return 1;
        return 0;
    }
}que[310000];
map<node,int>mp;
int num[310000];
int z[310000];
int n,m,p;
int lower(int x){
    int l=1,r=n;
    int mid;
    while(l<=r){
        mid=(l+r)>>1;
        if(num[mid]>=x)r=mid-1;
        else l=mid+1;
    }
    return n-l+1;
}
int main()
{
    cin>>n>>p;
    node x;
    int a,b;
    for(int i=0;i<n;i++){
        scanf("%d%d",&que[i].x,&que[i].y);
        que[i].change();
        if(mp.find(que[i])!=mp.end())mp[que[i]]++;
        else{
            mp[que[i]]=1;
        }
        num[que[i].x]++,num[que[i].y]++;
    }
    long long ans=0;
    for(int i=1;i<=n;i++)z[i]=num[i];
    sort(num+1,num+n+1);
    for(int i=1;i<=n;i++){
                ans+=lower(p-num[i]);
        if(num[i]*2>=p)ans-=1;
    }
    for(int i=0;i<n;i++){
        if(mp[que[i]]!=-1&&z[que[i].x]+z[que[i].y]>=p&&p>z[que[i].x]+z[que[i].y]-mp[que[i]]){
            ans-=2;
            //cout<<i<<" "<<mp[que[i]]<<" "<<que[i].x<<"   "<<que[i].y<<endl;
        }

        mp[que[i]]=-1;
    }
    printf("%I64d\n",ans/2);
    return 0;
}


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

typedef pair<int,int> PII;
typedef long long LL;

const int N = 300005;

int n, p, x[N], y[N], cnt[N];

int main() {
    scanf("%d%d", &n, &p);
    map<PII,int> mp;
    for (int i = 0; i < n; ++i) {
        scanf("%d%d", x+i, y+i);
        if (x[i] > y[i]) swap(x[i], y[i]);
        cnt[--x[i]]++;
        cnt[--y[i]]++;
        mp[PII(x[i], y[i])]++;
    }
    LL ans = 0, fake = 0;
    for (map<PII,int>::iterator it = mp.begin(); it != mp.end(); ++it) {
        int xi = it->first.first;
        int yi = it->first.second;
        int ci = it->second;
        if (cnt[xi] + cnt[yi] - ci >= p) ;
        else if (cnt[xi] + cnt[yi] >= p) ++fake;
    }
    sort(cnt, cnt+n);
    LL pd2 = 0;
    for (int i = 0; i < n; ++i) {
        int k = lower_bound(cnt, cnt + n, p - cnt[i]) - cnt;
        if (k <= i) k = i + 1;
        ans += n - k;
//      printf("k = %d\n", k);
    }
    ans -= fake;
    printf("%I64d\n", ans);
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define MN 100005

int n,m;
int ok[MN],a[MN],mark[MN],fl;
struct M
{
    int ty,x;
}Q[MN];

int main()
{
    scanf("%d%d",&n,&m);
    char c; int last=0,first=0;
    for(int i=1;i<=m;++i)
    {
        c=getchar(); while(c!='+' && c!='-') c=getchar();
        Q[i].ty=(c=='+' ? 1 : -1); scanf("%d",&Q[i].x);
        mark[Q[i].x]=1;
        if(!a[Q[i].x])
        {
            a[Q[i].x]=Q[i].ty;
            if(Q[i].ty==-1) last+=1;
        }
    }

    int now=last,aa=0;
    for(int i=1;i<=m;++i)
    {

        if(Q[i].ty==-1)
        {
            now-=1;
            if(now!=0) ok[Q[i].x]=1;
            else
            {
                if(!aa)
                aa=Q[i].x;
                else if(aa!=Q[i].x) {fl=1;break;}
            }
        }
        else
        {
            if(now!=0) ok[Q[i].x]=1;
            else
            {
                if(!aa) aa=Q[i].x;
                else if(aa!=Q[i].x) {fl=1; break;}
            }
            now+=1;

        }
    }

    int num=0;
    for(int i=1;i<=n;++i)
    if(!ok[i] && !(fl && mark[i]))
    {
        ++num;
    }

    printf("%d\n",num);
    for(int i=1;i<=n;++i)
    if(!ok[i] && !(fl && mark[i]))
    {
        printf("%d ",i);
    }

    return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<stack>
#include<set>
#include<queue>
#include<string>
#include<cstring>
#include<cmath>
#include<map>

#define lson L,M,now<<1
#define rson M+1,R,now<<1|1

using namespace std;
int N,P;

map< pair<int,int> ,int> mp;
vector<int> v[300005];
int cnt[300005];

int sum[300005<<2];

void update(int p,int L,int R,int now)
{
    if( p == L && p == R ){
        sum[now]++;
        return;
    }

    int M = (L+R)/2;
    if( p <= M )update(p,lson);
    else update(p,rson);
    sum[now] = sum[now<<1] + sum[now<<1|1];
}

int query(int l,int r,int L,int R,int now)
{
    if( l <= L && R <= r ){
        return sum[now];
    }

    int M=(L+R)/2;
    int res = 0;
    if( l <= M )res += query(l,r,lson);
    if( r >  M )res += query(l,r,rson);
    return res;
}

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("pa.out","w",stdout);
    int a,b,aa,bb;
    scanf(" %d %d",&N,&P);

    mp.clear();
    memset(cnt,0,sizeof(cnt));
    memset(sum,0,sizeof(sum));

    for( int i = 1; i <= N; i++ ){
        scanf(" %d %d",&a,&b);
        aa = min(a,b);
        bb = max(a,b);
        if( mp.find(make_pair(aa,bb)) == mp.end() ){
            mp.insert(make_pair(make_pair(aa,bb),1));
            v[aa].push_back(bb);
        }else{
            mp[make_pair(aa,bb)]++;
        }
        cnt[aa]++; cnt[bb]++;
    }

    long long res=0;
    for( int i = N; i >= 1; i-- ){
        res += query(max(0,P-cnt[i]),N,0,N,1);
        for(int j = 0; j < int(v[i].size()); j++ ){
            if( cnt[j]+cnt[i] >= P && cnt[j]+cnt[i]-mp[make_pair(i,j)] < P )res--;
        }
        update(cnt[i],0,N,1);
    }
    printf("%I64d\n",res);

    return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<stack>
#include<set>
#include<queue>
#include<string>
#include<cstring>
#include<cmath>
#include<map>

#define lson L,M,now<<1
#define rson M+1,R,now<<1|1

using namespace std;
int N,P;

map< pair<int,int> ,int> mp;
vector<int> v[300005];
int cnt[300005];

int sum[300005<<2];

void update(int p,int L,int R,int now)
{
    if( p == L && p == R ){
        sum[now]++;
        return;
    }

    int M = (L+R)/2;
    if( p <= M )update(p,lson);
    else update(p,rson);
    sum[now] = sum[now<<1] + sum[now<<1|1];
}

int query(int l,int r,int L,int R,int now)
{
    if( l <= L && R <= r ){
        return sum[now];
    }

    int M=(L+R)/2;
    int res = 0;
    if( l <= M )res += query(l,r,lson);
    if( r >  M )res += query(l,r,rson);
    return res;
}

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("pa.out","w",stdout);
    int a,b,aa,bb;
    scanf(" %d %d",&N,&P);

    mp.clear();
    memset(cnt,0,sizeof(cnt));
    memset(sum,0,sizeof(sum));

    for( int i = 1; i <= N; i++ ){
        scanf(" %d %d",&a,&b);
        aa = min(a,b);
        bb = max(a,b);
        if( mp.find(make_pair(aa,bb)) == mp.end() ){
            mp.insert(make_pair(make_pair(aa,bb),1));
            v[aa].push_back(bb);
        }else{
            mp[make_pair(aa,bb)]++;
        }
        cnt[aa]++; cnt[bb]++;
    }

    long long res=0;
    for( int i = N; i >= 1; i-- ){
        res += query(max(0,P-cnt[i]),N,0,N,1);
        for(int j = 0; j < int(v[i].size()); j++ ){
            if( cnt[v[i][j]]+cnt[i] >= P && cnt[v[i][j]]+cnt[i]-mp[make_pair(i,v[i][j])] < P )res--;
        }
        update(cnt[i],0,N,1);
    }
    printf("%I64d\n",res);

    return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <sstream>
#include <set>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <bitset>

using namespace std;

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

#define PB push_back
#define MP make_pair
#define CC(a, b) memset(a, b, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define SZ(a) ((int)a.size())
#define lowbit(x) ((x) & (-x))
#define foreach(it, a) for(__typeof((a).begin()) it=(a).begin(); it!=(a).end(); it++)
#define lson l, m, rt << 1
#define rson m + 1, r, rt << 1 | 1
#define x first
#define y second

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;

const int inf = 0x7f7f7f7f;
const LL infll = 0x7f7f7f7f7f7f7f7fll;
const int maxn = 333333;
const int mod = 1000000007;
const double eps = 1e-8;

struct node {
    int a, b;
    friend bool operator < (const node &a, const node &b) {
        if(a.a != b.a) return a.a < b.a;
        return a.b < b.b;
    }
}f[maxn];
int n, p, tot;
int cnt[maxn];
int sum[maxn];
int num[maxn];

int main()
{
    int i, j, t, cas=0;
    int a, b, c;
    while(scanf("%d%d", &n, &p) != EOF) {
        memset(cnt, 0, sizeof(cnt));
        memset(sum, 0, sizeof(sum));
        for(i = 1; i <= n; i++) {
            scanf("%d%d", &f[i].a, &f[i].b);
            cnt[f[i].a]++;
            cnt[f[i].b]++;
        }

         if(p == 0) {
            LL ret = n;
            ret *= n - 1;
            ret /= 2;
            cout << ret << endl;
            continue;
        }

        sort(f + 1, f + 1 + n);

        for(i = 1; i <= n; i++) sum[cnt[i]]++;
        for(i = 1; i <= n; i++) sum[i] += sum[i - 1];

        int tot = 1;
        num[1] = 1;
        for(i = 2; i <= n; i++) {
            if(f[i].a == f[i - 1].a && f[i].b == f[i - 1].b) {
                num[tot]++;
            }else {
                tot++;
                f[tot].a = f[i].a;
                f[tot].b = f[i].b;
                num[tot] = 1;
            }
        }

        LL ret = 0;
        for(i = 1; i <= n; i++) {
            if(cnt[i] >= p) ret += n - 1;
            else {
                ret += (n - sum[(p - cnt[i] - 1)]);
                if(cnt[i] + cnt[i] >= p) ret--;
            }
        }
        ret /= 2;

        for(i = 1; i <= tot; i++) {
            a = f[i].a;
            b = f[i].b;
            c = num[i];
            if(cnt[a] + cnt[b] >= p) {
                if(cnt[a] + cnt[b] - c < p) ret--;
            }
        }

        cout << ret << endl;
    }
    return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <sstream>
#include <set>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <bitset>

using namespace std;

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

#define PB push_back
#define MP make_pair
#define CC(a, b) memset(a, b, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define SZ(a) ((int)a.size())
#define lowbit(x) ((x) & (-x))
#define foreach(it, a) for(__typeof((a).begin()) it=(a).begin(); it!=(a).end(); it++)
#define lson l, m, rt << 1
#define rson m + 1, r, rt << 1 | 1
#define x first
#define y second

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;

const int inf = 0x7f7f7f7f;
const LL infll = 0x7f7f7f7f7f7f7f7fll;
const int maxn = 333333;
const int mod = 1000000007;
const double eps = 1e-8;

struct node {
    int a, b;
    friend bool operator < (const node &a, const node &b) {
        if(a.a != b.a) return a.a < b.a;
        return a.b < b.b;
    }
}f[maxn];
int n, p, tot;
int cnt[maxn];
int sum[maxn];
int num[maxn];

int main()
{
    int i, j, t, cas=0;
    int a, b, c;
    while(scanf("%d%d", &n, &p) != EOF) {
        memset(cnt, 0, sizeof(cnt));
        memset(sum, 0, sizeof(sum));
        for(i = 1; i <= n; i++) {
            scanf("%d%d", &f[i].a, &f[i].b);
            if(f[i].a > f[i].b) swap(f[i].a, f[i].b);
            cnt[f[i].a]++;
            cnt[f[i].b]++;
        }

         if(p == 0) {
            LL ret = n;
            ret *= n - 1;
            ret /= 2;
            cout << ret << endl;
            continue;
        }

        sort(f + 1, f + 1 + n);

        for(i = 1; i <= n; i++) sum[cnt[i]]++;
        for(i = 1; i <= n; i++) sum[i] += sum[i - 1];

        int tot = 1;
        num[1] = 1;
        for(i = 2; i <= n; i++) {
            if(f[i].a == f[i - 1].a && f[i].b == f[i - 1].b) {
                num[tot]++;
            }else {
                tot++;
                f[tot].a = f[i].a;
                f[tot].b = f[i].b;
                num[tot] = 1;
            }
        }

        LL ret = 0;
        for(i = 1; i <= n; i++) {
            if(cnt[i] >= p) ret += n - 1;
            else {
                ret += (n - sum[(p - cnt[i] - 1)]);
                if(cnt[i] + cnt[i] >= p) ret--;
            }
        }
        ret /= 2;

        for(i = 1; i <= tot; i++) {
            a = f[i].a;
            b = f[i].b;
            c = num[i];
            if(cnt[a] + cnt[b] >= p) {
                if(cnt[a] + cnt[b] - c < p) ret--;
            }
        }

        cout << ret << endl;
    }
    return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <sstream>
#include <set>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <bitset>

using namespace std;

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

#define PB push_back
#define MP make_pair
#define CC(a, b) memset(a, b, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define SZ(a) ((int)a.size())
#define lowbit(x) ((x) & (-x))
#define foreach(it, a) for(__typeof((a).begin()) it=(a).begin(); it!=(a).end(); it++)
#define lson l, m, rt << 1
#define rson m + 1, r, rt << 1 | 1
#define x first
#define y second

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;

const int inf = 0x7f7f7f7f;
const LL infll = 0x7f7f7f7f7f7f7f7fll;
const int maxn = 333333;
const int mod = 1000000007;
const double eps = 1e-8;

struct node {
    int a, b;
    friend bool operator < (const node &a, const node &b) {
        if(a.a != b.a) return a.a < b.a;
        return a.b < b.b;
    }
}f[maxn];
int n, p, tot;
int cnt[maxn];
int sum[maxn];
int num[maxn];

int main()
{
    int i, j, t, cas=0;
    int a, b, c;
    while(scanf("%d%d", &n, &p) != EOF) {
        memset(cnt, 0, sizeof(cnt));
        memset(sum, 0, sizeof(sum));
        for(i = 1; i <= n; i++) {
            scanf("%d%d", &f[i].a, &f[i].b);
            cnt[f[i].a]++;
            cnt[f[i].b]++;
        }
        sort(f + 1, f + 1 + n);

        for(i = 1; i <= n; i++) sum[cnt[i]]++;
        for(i = 1; i <= n; i++) sum[i] += sum[i - 1];

        int tot = 1;
        num[1] = 1;
        for(i = 2; i <= n; i++) {
            if(f[i].a == f[i - 1].a && f[i].b == f[i - 1].b) {
                num[tot]++;
            }else {
                tot++;
                f[tot].a = f[i].a;
                f[tot].b = f[i].b;
                num[tot] = 1;
            }
        }

        LL ret = 0;
        for(i = 1; i <= n; i++) {
            if(cnt[i] >= p) ret += n - 1;
            else {
                ret += (n - sum[(p - cnt[i] - 1)]);
                if(cnt[i] + cnt[i] >= p) ret--;
            }
        }
        ret /= 2;

        for(i = 1; i <= tot; i++) {
            a = f[i].a;
            b = f[i].b;
            c = num[i];
            if(cnt[a] + cnt[b] >= p) {
                if(cnt[a] + cnt[b] - c < p) ret--;
            }
        }

        cout << ret << endl;
    }
    return 0;
}


#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>

using namespace std;

#define N 300000
#define LL long long
int d[N];
vector<pair<int,int> > vec;
vector<int> tmpd;

int main(){
	int n,p;
	scanf("%d%d",&n,&p);
	for(int i = 0 ; i < n ; ++i){
		int u,v;
		scanf("%d%d",&u,&v);
		d[u] ++ ,d[v] ++;
		if(u > v) swap(u,v);
		vec.push_back(make_pair(u,v));
	}
	LL ans = 0;
	for(int i = 1 ; i <= n ; ++i)	tmpd.push_back(d[i]);
	sort(tmpd.begin(),tmpd.end());
	for(int i = 0 ; i < n ; ++i){
		int pos = lower_bound(tmpd.begin(),tmpd.end(),p - d[i]) - tmpd.begin();
		ans += (LL)n - pos;
		if(d[i] + d[i] >= p)	ans --;
	}
	ans /= 2;
	sort(vec.begin(),vec.end());
	int cnt = 0,u = 0, v = 0;
	for(int i = 0 ; i < n;  ++i){
		if(!(u == vec[i].first && v == vec[i].second)){
			if(d[u] + d[v] >= p)	ans --;
			if(d[u] + d[v] - cnt >= p)	ans ++;
			cnt = 1;
			u = vec[i].first,v = vec[i].second;
		}
		else	cnt ++;
	}
	printf("%I64d\n",ans);
	return 0;
}


#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>

using namespace std;

#define N 300000
#define LL long long
int d[N];
vector<pair<int,int> > vec;
vector<int> tmpd;

int main(){
	int n,p;
	scanf("%d%d",&n,&p);
	for(int i = 0 ; i < n ; ++i){
		int u,v;
		scanf("%d%d",&u,&v);
		d[u] ++ ,d[v] ++;
		if(u > v) swap(u,v);
		vec.push_back(make_pair(u,v));
	}
	LL ans = 0;
	for(int i = 1 ; i <= n ; ++i)	tmpd.push_back(d[i]);
	sort(tmpd.begin(),tmpd.end());
	for(int i = 1 ; i <= n ; ++i){
		int pos = lower_bound(tmpd.begin(),tmpd.end(),p - d[i]) - tmpd.begin();
		ans += (LL)n - pos;
		if(d[i] + d[i] >= p)	ans --;
	}
	ans /= 2;
	sort(vec.begin(),vec.end());
	int cnt = 0,u = 0, v = 0;
	for(int i = 0 ; i < n;  ++i){
		if(!(u == vec[i].first && v == vec[i].second)){
			if(d[u] + d[v] >= p)	ans --;
			if(d[u] + d[v] - cnt >= p)	ans ++;
			cnt = 1;
			u = vec[i].first,v = vec[i].second;
		}
		else	cnt ++;
	}
	if(d[u]+d[v] >= p)	ans --;
	if(d[u] + d[v] - cnt >= p)	ans ++;
	printf("%I64d\n",ans);
	return 0;
}


#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>

using namespace std;

#define N 300000
#define LL long long
int d[N];
vector<pair<int,int> > vec;
vector<int> tmpd;

int main(){
	int n,p;
	scanf("%d%d",&n,&p);
	for(int i = 0 ; i < n ; ++i){
		int u,v;
		scanf("%d%d",&u,&v);
		d[u] ++ ,d[v] ++;
		if(u > v) swap(u,v);
		vec.push_back(make_pair(u,v));
	}
	LL ans = 0;
	for(int i = 1 ; i <= n ; ++i)	tmpd.push_back(d[i]);
	sort(tmpd.begin(),tmpd.end());
	for(int i = 0 ; i < n ; ++i){
		int pos = lower_bound(tmpd.begin(),tmpd.end(),p - d[i]) - tmpd.begin();
		ans += (LL)n - pos;
		if(d[i] + d[i] >= p)	ans --;
	}
	ans /= 2;
	sort(vec.begin(),vec.end());
	int cnt = 0,u = 0, v = 0;
	for(int i = 0 ; i < n;  ++i){
		if(!(u == vec[i].first && v == vec[i].second)){
			if(d[u] + d[v] >= p)	ans --;
			if(d[u] + d[v] - cnt >= p)	ans ++;
			cnt = 1;
			u = vec[i].first,v = vec[i].second;
		}
		else	cnt ++;
	}
	if(d[u]+d[v] >= p)	ans --;
	if(d[u] + d[v] - cnt >= p)	ans ++;
	printf("%I64d\n",ans);
	return 0;
}


#include<stdio.h>
#include<algorithm>
using namespace std;
const int maxn=300050;
int n,p;
long long ans=0;
int de[maxn]={0},tr[maxn]={0};
int es=0,he[maxn],to[maxn*2],ne[maxn*2];
inline int lowbit(int x) { return x&(-x); }
void add(int x,int k)
{
	while(x<maxn)
		tr[x]+=k,x+=lowbit(x);
}
int que(int x)
{
	int s=0;
	while(x)
		s+=tr[x],x-=lowbit(x);
	return s;
}
void ins(int u,int v)
{
	to[++es]=v;
	ne[es]=he[u];
	he[u]=es;
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("data.in","r",stdin);
	freopen("data.out","w",stdout);
#endif
	int i,j,k,x,y;
	scanf("%d%d",&n,&p);
	for(i=0;i<n;i++)
		scanf("%d%d",&x,&y),de[x]++,de[y]++,ins(x,y),ins(y,x);
	for(i=1;i<=n;i++)
		add(n-de[i]+1,1);
	for(i=1;i<=n;i++)
	{
		for(j=he[i];j;j=ne[j])
		{
			k=to[j];
			add(n-de[k]+1,-1);
			de[k]--;
			add(n-de[k]+1,1);
		}
		add(n-de[i]+1,-1);
		ans+=que(n-max(0,p-de[i])+1);
		add(n-de[i]+1,1);
		for(j=he[i];j;j=ne[j])
		{
			k=to[j];
			add(n-de[k]+1,-1);
			de[k]++;
			add(n-de[k]+1,1);
		}
	}
	printf("%I64d\n",ans/2);
	return 0;
}


#include<stdio.h>
#include<algorithm>
using namespace std;
const int maxn=300050;
int n,p,ans=0;
int de[maxn]={0},tr[maxn]={0};
int es=0,he[maxn],to[maxn*2];
inline int lowbit(int x) { return x&(-x); }
void add(int x,int k)
{
	while(x<maxn)
		tr[x]+=k,x+=lowbit(x);
}
int que(int x)
{
	int s=0;
	while(x)
		s+=tr[x],x-=lowbit(x);
	return s;
}
void ins(int u,int v)
{
	to[++es]=he[u];
	he[u]=es;
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("data.in","r",stdin);
#endif
	int i,j,k,x,y;
	scanf("%d%d",&n,&p);
	for(i=0;i<n;i++)
		scanf("%d%d",&x,&y),de[x]++,de[y]++,ins(x,y);
	for(i=1;i<=n;i++)
		add(maxn-de[i],1);
	for(i=1;i<=n;i++)
	{
		pair<int,int> cur;
		for(j=he[i];j;j=to[j])
		{
			k=to[j];
			add(maxn-de[k],-1);
			de[k]--;
			add(maxn-de[k],1);
		}
		add(maxn-de[i],-1);
		ans+=que(maxn-p+de[i]);
		add(maxn-de[i],1);
		for(j=he[i];j;j=to[j])
		{
			k=to[j];
			add(maxn-de[k],-1);
			de[k]++;
			add(maxn-de[k],1);
		}
	}
	printf("%d\n",ans);
	return 0;
}


#include<stdio.h>
#include<algorithm>
using namespace std;
const int maxn=300050;
int n,p,ans=0;
int de[maxn]={0},tr[maxn]={0};
int es=0,he[maxn],to[maxn*2],ne[maxn*2];
inline int lowbit(int x) { return x&(-x); }
void add(int x,int k)
{
	while(x<maxn)
		tr[x]+=k,x+=lowbit(x);
}
int que(int x)
{
	int s=0;
	while(x)
		s+=tr[x],x-=lowbit(x);
	return s;
}
void ins(int u,int v)
{
	to[++es]=v;
	ne[es]=he[u];
	he[u]=es;
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("data.in","r",stdin);
	freopen("data.out","w",stdout);
#endif
	int i,j,k,x,y;
	scanf("%d%d",&n,&p);
	for(i=0;i<n;i++)
		scanf("%d%d",&x,&y),de[x]++,de[y]++,ins(x,y);
	for(i=1;i<=n;i++)
		add(n-de[i]+1,1);
	for(i=1;i<=n;i++)
	{
		pair<int,int> cur;
		for(j=he[i];j;j=ne[j])
		{
			k=to[j];
			add(n-de[k]+1,-1);
			de[k]--;
			add(n-de[k]+1,1);
		}
		add(n-de[i]+1,-1);
		ans+=que(n-p+de[i]+1);
		add(n-de[i]+1,1);
		for(j=he[i];j;j=ne[j])
		{
			k=to[j];
			add(n-de[k]+1,-1);
			de[k]++;
			add(n-de[k]+1,1);
		}
	}
	printf("%d\n",ans/2);
	return 0;
}


#include<stdio.h>
#include<algorithm>
using namespace std;
const int maxn=300050;
int n,p;
long long ans=0;
int de[maxn]={0},tr[maxn]={0};
int es=0,he[maxn],to[maxn*2],ne[maxn*2];
inline int lowbit(int x) { return x&(-x); }
void add(int x,int k)
{
	while(x<maxn)
		tr[x]+=k,x+=lowbit(x);
}
int que(int x)
{
	int s=0;
	while(x)
		s+=tr[x],x-=lowbit(x);
	return s;
}
void ins(int u,int v)
{
	to[++es]=v;
	ne[es]=he[u];
	he[u]=es;
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("data.in","r",stdin);
	freopen("data.out","w",stdout);
#endif
	int i,j,k,x,y;
	scanf("%d%d",&n,&p);
	for(i=0;i<n;i++)
		scanf("%d%d",&x,&y),de[x]++,de[y]++,ins(x,y),ins(y,x);
	for(i=1;i<=n;i++)
		add(n-de[i]+1,1);
	for(i=1;i<=n;i++)
	{
		for(j=he[i];j;j=ne[j])
		{
			k=to[j];
			add(n-de[k]+1,-1);
			de[k]--;
			add(n-de[k]+1,1);
		}
		add(n-de[i]+1,-1);
		ans+=que(n-p+de[i]+1);
		add(n-de[i]+1,1);
		for(j=he[i];j;j=ne[j])
		{
			k=to[j];
			add(n-de[k]+1,-1);
			de[k]++;
			add(n-de[k]+1,1);
		}
	}
	printf("%I64d\n",ans/2);
	return 0;
}


#include<iostream>
#include<list>
#include<algorithm>
#include<set>
using namespace std;
struct P{
	int num,v;
};
P d[500000];
set<int> mm[500000];
int now[500000];
int n,m,x,y;
int ans=0;
bool cmp(P x,P y)
{
	return x.v>y.v;
}
int solve(int v)
{
	int l,r,mid;
	l=1;
	r=n;
	do
	{
		mid=(l+r)/2;
		if(v<=d[mid].v)
			l=mid;
		else
			r=mid-1;
	}while(l+1<r);
	if(d[l+1].v>=v)return l+1;
	return l;
}
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		cin>>x>>y;
		d[i].num=i;
		d[x].v++;
		d[y].v++;
		mm[x].insert(y);
		mm[y].insert(x);
	}
	sort(&d[1],&d[n+1],cmp);
	for(int i=1;i<=n;i++)
		now[d[i].num]=i;
	for(int i=1;i<=n;i++)
	{
		if(d[i].v>=m)
		{
			ans+=n-i;
			continue;
		}
		int p=solve(m-d[i].v);
		if(p<=i)continue;
		ans+=p-i;
		set<int>::iterator it;
		for(it=mm[d[i].num].begin();it!=mm[d[i].num].end();++it)
		{
			if(now[*it]>i&&now[*it]<=p&&d[i].v+d[now[*it]].v-mm[d[i].num].count(*it)<m)
				ans--;
		}
	}
	cout<<ans<<endl;
}


#include<iostream>
#include<list>
#include<algorithm>
#include<set>
using namespace std;
struct P{
	int num,v;
};
P d[500000];
multiset<int> mm[500000];
int now[500000];
int n,m,x,y;
int ans=0;
bool cmp(P x,P y)
{
	return x.v>y.v;
}
int solve(int v)
{
	int l,r,mid;
	l=1;
	r=n;
	do
	{
		mid=(l+r)/2;
		if(v<=d[mid].v)
			l=mid;
		else
			r=mid-1;
	}while(l+1<r);
	if(d[l+1].v>=v)return l+1;
	return l;
}
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		cin>>x>>y;
		d[i].num=i;
		d[x].v++;
		d[y].v++;
		mm[x].insert(y);
		mm[y].insert(x);
	}
	sort(&d[1],&d[n+1],cmp);
	for(int i=1;i<=n;i++)
		now[d[i].num]=i;
	for(int i=1;i<=n;i++)
	{
		if(d[i].v>=m)
		{
			ans+=n-i;
			continue;
		}
		int p=solve(m-d[i].v);
		if(p<=i)continue;
		ans+=p-i;
		set<int>::iterator it;
		while(!mm[d[i].num].empty())
		{
			it=mm[d[i].num].begin();
			if(now[*it]>i&&now[*it]<=p&&d[i].v+d[now[*it]].v-mm[d[i].num].count(*it)<m)
				ans--;
			mm[d[i].num].erase(*it);
		}
	}
	cout<<ans<<endl;
	return 0;
}


#include<iostream>
#include<list>
#include<algorithm>
#include<set>
using namespace std;
struct P{
	int num,v;
};
P d[500000];
multiset<int> mm[500000];
int now[500000];
int n,m,x,y;
long long ans=0;
bool cmp(P x,P y)
{
	return x.v>y.v;
}
int solve(int v)
{
	int l,r,mid;
	l=1;
	r=n;
	do
	{
		mid=(l+r)/2;
		if(v<=d[mid].v)
			l=mid;
		else
			r=mid-1;
	}while(l+1<r);
	if(d[l+1].v>=v)return l+1;
	return l;
}
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		cin>>x>>y;
		d[i].num=i;
		d[x].v++;
		d[y].v++;
		mm[x].insert(y);
		mm[y].insert(x);
	}
	sort(&d[1],&d[n+1],cmp);
	for(int i=1;i<=n;i++)
		now[d[i].num]=i;
	for(int i=1;i<=n;i++)
	{
		if(d[i].v>=m)
		{
			ans+=n-i;
			continue;
		}
		int p=solve(m-d[i].v);
		if(p<=i)continue;
		ans+=p-i;
		set<int>::iterator it;
		while(!mm[d[i].num].empty())
		{
			it=mm[d[i].num].begin();
			if(now[*it]>i&&now[*it]<=p&&d[i].v+d[now[*it]].v-mm[d[i].num].count(*it)<m)
				ans--;
			mm[d[i].num].erase(*it);
		}
	}
	cout<<ans<<endl;
	return 0;
}


#include<iostream>
#include<list>
#include<algorithm>
#include<set>
using namespace std;
typedef long long int;
struct P{
	int num,v;
};
P d[500000];
multiset<int> mm[500000];
int now[500000];
int n,m,x,y;
int ans=0;
bool cmp(P x,P y)
{
	return x.v>y.v;
}
int solve(int v)
{
	int l,r,mid;
	l=1;
	r=n;
	do
	{
		mid=(l+r)/2;
		if(v<=d[mid].v)
			l=mid;
		else
			r=mid-1;
	}while(l+1<r);
	if(d[l+1].v>=v)return l+1;
	return l;
}
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		cin>>x>>y;
		d[i].num=i;
		d[x].v++;
		d[y].v++;
		mm[x].insert(y);
		mm[y].insert(x);
	}
	sort(&d[1],&d[n+1],cmp);
	for(int i=1;i<=n;i++)
		now[d[i].num]=i;
	for(int i=1;i<=n;i++)
	{
		if(d[i].v>=m)
		{
			ans+=n-i;
			continue;
		}
		int p=solve(m-d[i].v);
		if(p<=i)continue;
		ans+=p-i;
		set<int>::iterator it;
		while(!mm[d[i].num].empty())
		{
			it=mm[d[i].num].begin();
			if(now[*it]>i&&now[*it]<=p&&d[i].v+d[now[*it]].v-mm[d[i].num].count(*it)<m)
				ans--;
			mm[d[i].num].erase(*it);
		}
	}
	cout<<ans<<endl;
	return 0;
}


#include "cstdio"
#include "algorithm"
#include "string"
#include "vector"
#include "map"
using namespace std;
#define ll long long
#define ull unsigned long long

map<pair<int,int>,int>pb;

const int maxn=300500;
ull cnt[maxn];
ull ans,n,p;

int main()
{
	scanf("%llu%llu",&n,&p);

	for(int i=1;i<=n;i++)
	{
		ull u,v;
		scanf("%llu%llu",&u,&v);

		cnt[u]++;
		cnt[v]++;

		if(u>v)swap(v,u);
		pb[make_pair(u,v)]++;
	}

	for(map<pair<int,int>,int>::iterator it=pb.begin(),d=pb.end();it!=d;it++)
	{
		int s1=((*it).first).first;
		int s2=((*it).first).second;
		int res=cnt[s1]+cnt[s2];

		if(res>=p && res-(*it).second<p)
			ans--;
	}

	sort(cnt+1,cnt+n+1);

	int top=n;
	for(int i=1;i<=n;i++)
	{
		top=max(i,top);
		while(i<top && cnt[i]+cnt[top]>=p)top--;
		ans+=n-top;
	}

	printf("%llu\n",ans);
	return 0;
}


#include "cstdio"
#include "algorithm"
#include "string"
#include "vector"
#include "map"
using namespace std;
#define ll long long
#define ull unsigned long long

map<pair<int,int>,int>pb;

const int maxn=300500;
ull cnt[maxn];
ull res[maxn],p;
ull ans,n,m;

int cmp(int i,int j)
{
	return cnt[i]>cnt[j];
}

int main()
{
	scanf("%llu%llu",&n,&m);

	for(int i=1;i<=n;i++)
	{
		ull u,v;
		scanf("%llu%llu",&u,&v);
		//cout<<"#"<<u<<" "<<v<<endl;
		cnt[u]++;
		cnt[v]++;

		if(u>v)swap(v,u);
		pb[make_pair(u,v)]++;
	}

//	for(int i=1;i<=n;i++)
//	{
//		printf("# %d %d\n",i,cnt[i]);
//	}

	ull ps=0;
	for(int i=1;i<=n;i++)
	{
		if(cnt[i]>=m)
			ps++;
		else
			res[++p]=i;
	}

	//printf("###%d\n",ps);
	ans=n*ps-((1LL+ps)*ps>>1);
	//printf("###%llu",ans);
	//for(int i=1;i<=p;i++)
	//	printf("%d\n",res[i]);
	sort(res+1,res+p+1,cmp);

	int top=p;
	int s1,s2;

	for(int i=1;i<p;i++)
		for(int j=i+1;j<=top;j++)
		{
			s1=res[i];
			s2=res[j];

			//printf("#%d %d %d\n",s1,s2,pb[make_pair(s1,s2)]);

			if(cnt[s1]+cnt[s2]<m)
			{
				top=j;
				continue;
			}

			if(cnt[s1]+cnt[s2]-pb[make_pair(s1,s2)] >= m)
			{
				//printf("#%d %d\n",s1,s2);
				ans++;
			}
		}

	printf("%llu\n",ans);
	return 0;
}


#include "cstdio"
#include "algorithm"
#include "string"
#include "vector"
#include "map"
using namespace std;
#define ll long long
#define ull unsigned long long

map<pair<int,int>,int>pb;

const int maxn=300500;
ull cnt[maxn];
ull res[maxn],p;
ull ans,n,m;

int cmp(int i,int j)
{
	return cnt[i]>cnt[j];
}

int main()
{
	scanf("%llu%llu",&n,&m);

	for(int i=1;i<=n;i++)
	{
		ull u,v;
		scanf("%llu%llu",&u,&v);
		//cout<<"#"<<u<<" "<<v<<endl;
		cnt[u]++;
		cnt[v]++;

		if(u>v)swap(v,u);
		pb[make_pair(u,v)]++;
	}

//	for(int i=1;i<=n;i++)
//	{
//		printf("# %d %d\n",i,cnt[i]);
//	}

	int ps=0;
	for(int i=1;i<=n;i++)
	{
		if(cnt[i]>=m)
			ps++;
		else
			res[++p]=i;
	}

	//printf("###%d\n",ps);
	ans=n*ps-((1+ps)*ps>>1);
	//printf("###%llu",ans);
	//for(int i=1;i<=p;i++)
	//	printf("%d\n",res[i]);
	sort(res+1,res+p+1,cmp);

	int top=p;
	int s1,s2;

	for(int i=1;i<p;i++)
		for(int j=i+1;j<=top;j++)
		{
			s1=res[i];
			s2=res[j];

			//printf("#%d %d %d\n",s1,s2,pb[make_pair(s1,s2)]);

			if(cnt[s1]+cnt[s2]<m)
			{
				top=j;
				continue;
			}

			if(cnt[s1]+cnt[s2]-pb[make_pair(s1,s2)] >= m)
			{
				//printf("#%d %d\n",s1,s2);
				ans++;
			}
		}

	printf("%llu\n",ans);
	return 0;
}


#include "cstdio"
#include "algorithm"
#include "string"
#include "vector"
#include "map"
using namespace std;
#define ll long long
#define ull unsigned long long

map<pair<int,int>,int>pb;

const int maxn=300500;
ull cnt[maxn];
ull res[maxn],p;
ull ans,n,m;

int cmp(int i,int j)
{
	return cnt[i]>cnt[j];
}

int main()
{
	scanf("%llu%llu",&n,&m);

	for(int i=1;i<=n;i++)
	{
		ull u,v;
		scanf("%llu%llu",&u,&v);
		//cout<<"#"<<u<<" "<<v<<endl;
		cnt[u]++;
		cnt[v]++;
		pb[make_pair(u,v)]++;
	}

//	for(int i=1;i<=n;i++)
//	{
//		printf("# %d %d\n",i,cnt[i]);
//	}

	int ps=0;
	for(int i=1;i<=n;i++)
	{
		if(cnt[i]>=m)
		{
			ps++;
		}
		else
			res[++p]=i;
	}

	ans=n*ps-((1+ps)*ps>>1);

	//for(int i=1;i<=p;i++)
	//	printf("%d\n",res[i]);
	sort(res+1,res+p+1,cmp);

	int top=p;
	int s1,s2;

	for(int i=1;i<p;i++)
		for(int j=i+1;j<=top;j++)
		{
			s1=res[i];
			s2=res[j];

			//printf("#%d %d %d\n",s1,s2,pb[make_pair(s1,s2)]);

			if(cnt[s1]+cnt[s2]<m)
			{
				top=j;
				continue;
			}

			if(cnt[s1]+cnt[s2]-pb[make_pair(s1,s2)] >= m)
				ans++;
		}

	printf("%llu\n",ans);
	return 0;
}


#include "cstdio"
#include "algorithm"
#include "string"
#include "vector"
#include "map"
using namespace std;
#define ll long long
#define ull unsigned long long

map<pair<int,int>,int>pb;

const int maxn=300500;
ull cnt[maxn];
ull res[maxn],p;
ull ans,n,m;

int cmp(int i,int j)
{
	return cnt[i]>cnt[j];
}

int main()
{
	scanf("%llu%llu",&n,&m);

	for(int i=1;i<=n;i++)
	{
		ull u,v;
		scanf("%llu%llu",&u,&v);

		cnt[u]++;
		cnt[v]++;

		if(u>v)swap(v,u);
		pb[make_pair(u,v)]++;
	}

	for(map<pair<int,int>,int>::iterator it=pb.begin(),d=pb.end();it!=d;it++)
	{
		int s1=((*it).first).first;
		int s2=((*it).first).second;
		int res=cnt[s1]+cnt[s2];

		if(res>=p && res-(*it).second<p)
			ans--;
	}

	int now=n;

	for(int i=1;i<=n;i++)
	{
		now=max(i,now);
		while(i<now && cnt[i]+cnt[now]>=p)now--;
		ans+=n-now;
	}

	printf("%llu\n",ans);
	return 0;
}


#include "cstdio"
#include "algorithm"
#include "string"
#include "vector"
#include "map"
using namespace std;
#define ll long long
#define ull unsigned long long

map<pair<int,int>,int>pb;

const int maxn=300500;
ull cnt[maxn];
ull res[maxn],p;
ull ans,n,m;

int cmp(int i,int j)
{
	return cnt[i]>cnt[j];
}

int main()
{
	scanf("%llu%llu",&n,&m);

	for(int i=1;i<=n;i++)
	{
		ull u,v;
		scanf("%llu%llu",&u,&v);
		//cout<<"#"<<u<<" "<<v<<endl;
		cnt[u]++;
		cnt[v]++;
		pb[make_pair(u,v)]++;
	}

//	for(int i=1;i<=n;i++)
//	{
//		printf("# %d %d\n",i,cnt[i]);
//	}

	int ps=0;
	for(int i=1;i<=n;i++)
	{
		if(cnt[i]>=m)
		{
			ps++;
		}
		else
			res[++p]=i;
	}

	ans=n*ps-((1+ps)*ps>>1);

	//for(int i=1;i<=p;i++)
	//	printf("%d\n",res[i]);
	sort(res+1,res+p+1,cmp);

	int top=p;
	int s1,s2;

	for(int i=1;i<p;i++)
		for(int j=i+1;j<=top;j++)
		{
			s1=res[i];
			s2=res[j];

			printf("#%d %d %d\n",s1,s2,pb[make_pair(s1,s2)]);

			if(cnt[s1]+cnt[s2]<m)
			{
				top=j;
				continue;
			}

			if(cnt[s1]+cnt[s2]-pb[make_pair(s1,s2)] >= m)
				ans++;
		}

	printf("%llu\n",ans);
	return 0;
}


#include <iostream>
#include <stdio.h>
#include <map>
#include <algorithm>
#include <utility>
using namespace std;

map<pair<int,int>,int> MAP;
int a[300005]={0},b[300005]={0};
int main()
{
    int n,p,sum=0;
    pair<int,int> tmp;
    cin >> n >> p ;
    for(int i=0;i<n;i++)
    {
        scanf("%d%d",&tmp.first,&tmp.second);
        if(tmp.first>tmp.second) swap(tmp.first,tmp.second);
        MAP[tmp]++;
        a[tmp.first]++;a[tmp.second]++;
        b[tmp.first]++;b[tmp.second]++;
    }
    sort(b+1,b+n+1);
    for(int i=n;i>0;i--)
    {
        sum+=i-(lower_bound(b+1,b+i,p-b[i])-b);
    }
    map< pair<int, int>, int>::iterator it;
    for(it=MAP.begin(); it!=MAP.end(); ++it)
    {
        int x=it->first.first, y=it->first.second;
        int tmp= it->second;
        if(a[x]+a[y]>=p && a[x]+a[y]-tmp<p) sum--;
    }

    cout << sum ;
    return 0;
}


#include <iostream>
#include <stdio.h>
#include <map>
#include <algorithm>
#include <utility>
using namespace std;

map<pair<int,int>,int> MAP;
int a[300005]={0},b[300005]={0};
int main()
{
    int n,p;
    long long sum=0;
    pair<int,int> tmp;
    cin >> n >> p ;
    for(int i=0;i<n;i++)
    {
        scanf("%d%d",&tmp.first,&tmp.second);
        if(tmp.first>tmp.second) swap(tmp.first,tmp.second);
        MAP[tmp]++;
        a[tmp.first]++;a[tmp.second]++;
        b[tmp.first]++;b[tmp.second]++;
    }
    sort(b+1,b+n+1);
    for(int i=n;i>0;i--)
    {
        sum+=i-(lower_bound(b+1,b+i,p-b[i])-b);
    }
    map< pair<int, int>, int>::iterator it;
    for(it=MAP.begin(); it!=MAP.end(); ++it)
    {
        int x=it->first.first, y=it->first.second;
        int tmp= it->second;
        if(a[x]+a[y]>=p && a[x]+a[y]-tmp<p) sum--;
    }
    cout << sum ;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <utility>

#define MAXN 300001

using namespace std;

int main() {
    int n, p, head, tail;
    long long comb = 0;
    int cnt[MAXN], sortedCnt[MAXN];
    pair<int, int> a[300000];
    cin >> n >> p;
    for (int i = 0; i < n; i++) {
        cin >> a[i].first >> a[i].second;
        cnt[a[i].first - 1]++;
        cnt[a[i].second - 1]++;
        if (a[i].first > a[i].second) {
            int tmp = a[i].first;
            a[i].first = a[i].second;
            a[i].second = tmp;
        }
    }
    copy(cnt, cnt + n, sortedCnt);
    sort(a, a + n);
    sort(sortedCnt, sortedCnt + n);
    /*for (int i = 0; i < n; i++) {
        cout << a[i].first << " " << a[i].second << endl;
    }*/
    head = 0;
    tail = n - 1;
    while(head < tail) {
        if (sortedCnt[head] + sortedCnt[tail] >= p) {
            comb += tail - head;
            tail--;
        } else {
            head++;
        }

    }
    head = 0;
    tail = 0;

    while (tail < n) {
        tail++;
        //move tail to find the degree of duplicate.
        if (!(a[head] == a[tail])) {
            int first = a[head].first - 1, second = a[head].second - 1;
            if (cnt[first] + cnt[second] >= p
                    && cnt[first] + cnt[second] - (tail - head) < p) {
                comb--;
            }
            head = tail;

        }
    }

    cout << comb << endl;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <utility>
using namespace std;

int main() {
    int n,p,head,tail,comb=0;
    int cnt[300000];
    pair<int,int> a[300000];
    cin>>n>>p;
    for(int i=0;i<n;i++){
        cin>>a[i].first>>a[i].second;
        cnt[a[i].first-1]++;
        cnt[a[i].second-1]++;
    }
    sort(a,a+n);
    sort(cnt,cnt+n);
    for(int i=0;i<n;i++){
        cout<<cnt[i]<<endl;
    }
    head = 0;
    tail = n-1;
    for(int i=0;i<n && head<tail;i++){
        if(cnt[head]+cnt[tail]>=p){
            comb += tail-head;
            tail--;
        }
        else{
            head++;
        }

    }
    head = 0;
    tail = 0;

    while(tail<n){
        tail++;
        //move tail to find the degree of duplicate.
        if(!(a[head]==a[tail])){
            int first = a[head].first,second = a[head].second;
            if(cnt[first] + cnt[second] >=p && cnt[first] + cnt[second] - (tail-head)<p){
                comb--;
                head = tail;
            }
        }
    }

    cout<<comb<<endl;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <utility>
using namespace std;

int main() {
    int n,p,head,tail,comb=0;
    int cnt[300000];
    pair<int,int> a[300000];
    cin>>n>>p;
    for(int i=0;i<n;i++){
        cin>>a[i].first>>a[i].second;
        cnt[a[i].first-1]++;
        cnt[a[i].second-1]++;
    }
    sort(a,a+n);
    sort(cnt,cnt+n);
    /*for(int i=0;i<n;i++){
        cout<<cnt[i]<<endl;
    }*/
    head = 0;
    tail = n-1;
    for(int i=0;i<n && head<tail;i++){
        if(cnt[head]+cnt[tail]>=p){
            comb += tail-head;
            tail--;
        }
        else{
            head++;
        }

    }
    head = 0;
    tail = 0;

    while(tail<n){
        tail++;
        //move tail to find the degree of duplicate.
        if(!(a[head]==a[tail])){
            int first = a[head].first,second = a[head].second;
            if(cnt[first] + cnt[second] >=p && cnt[first] + cnt[second] - (tail-head)<p){
                comb--;
                head = tail;
            }
        }
    }

    cout<<comb<<endl;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <utility>
using namespace std;

int main() {
    int n,p,head,tail,comb=0;
    int cnt[300000];
    pair<int,int> a[300000];
    cin>>n>>p;
    for(int i=0;i<n;i++){
        cin>>a[i].first>>a[i].second;
        cnt[a[i].first-1]++;
        cnt[a[i].second-1]++;
    }
    sort(cnt,cnt+n);
    /*for(int i=0;i<n;i++){
        cout<<cnt[i]<<endl;
    }*/
    head = 0;
    tail = n-1;
    for(int i=0;i<n;i++){
        if(cnt[head]+cnt[tail]>=p){
            comb += tail-head;
            tail--;
        }
        else{
            head++;
        }
    }
    cout<<comb<<endl;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <utility>

#define MAXN 300001

using namespace std;

int main() {
    int n, p, head, tail, comb = 0;
    int cnt[MAXN], sortedCnt[MAXN];
    pair<int, int> a[300000];
    cin >> n >> p;
    for (int i = 0; i < n; i++) {
        cin >> a[i].first >> a[i].second;
        cnt[a[i].first - 1]++;
        cnt[a[i].second - 1]++;
        if (a[i].first > a[i].second) {
            int tmp = a[i].first;
            a[i].first = a[i].second;
            a[i].second = tmp;
        }
    }
    copy(cnt, cnt + n, sortedCnt);
    sort(a, a + n);
    sort(sortedCnt, sortedCnt + n);
    /*for (int i = 0; i < n; i++) {
        cout << a[i].first << " " << a[i].second << endl;
    }*/
    head = 0;
    tail = n - 1;
    for (int i = 0; i < n && head < tail; i++) {
        if (sortedCnt[head] + sortedCnt[tail] >= p) {
            comb += tail - head;
            tail--;
        } else {
            head++;
        }

    }
    head = 0;
    tail = 0;

    while (tail < n) {
        tail++;
        //move tail to find the degree of duplicate.
        if (!(a[head] == a[tail])) {
            int first = a[head].first - 1, second = a[head].second - 1;
            if (cnt[first] + cnt[second] >= p
                    && cnt[first] + cnt[second] - (tail - head) < p) {
                comb--;
            }
            head = tail;

        }
    }

    cout << comb << endl;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
int n, p;
int a[300123], b[300123];
pair<int,int> e[300123];
long long cnt;
void check(pair<int,int> t, int z){
	int x = t.first;
	int y = t.second;
	if (b[x] + b[y] >= p
			&& b[x] + b[y]-  z < p)
		cnt --;
}
int main(){
	cin >> n >> p;
	for(int i = 1; i <= n; i ++){
		int x, y;
		cin >> x >> y;
		if (x > y) swap(x,y);
		a[x]++; a[y]++;
		b[x]++; b[y]++;
		e[i] = make_pair(x, y);
	};
	sort(a + 1, a + n + 1);

	int j = n;
	//cout << endl;
	//for(int i = 1; i <= n; i++)
		//cout << a[i] << "  ";
	//cout << endl;
	for(int i = 1; i <= n ; i++){
		while(j > 0 && a[i] + a[j] >= p) j--;
		cnt += n - j;
		//cout << i << " " << cnt << " " << j  << endl;
	}
	for(int i = 1; i<= n; i++)
		if (a[i] * 2 >= p)
			cnt--;
	cnt /= 2;
	//truncate
	sort(e + 1, e + n  + 1);
	int z = 1;
	for(int i = 2; i <= n + 1; i++)
		if (i == n + 1 || e[i] != e[i - 1]){
			check(e[i-1], z);
			z = 1;
		} else {
			z++;
		}
	cout << cnt;
	return 0;
}


#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
int n, p;
int a[300123], u[300123], v[300123], b[300123];
map<int, int> m[300123];
map<pair<int,int>, bool> checked;
int main(){
	cin >> n >> p;
	for(int i = 1; i <= n; i ++){
		int x, y;
		cin >> x >> y;
		a[x]++; a[y]++;
		b[x]++; b[y]++;
		m[x][y]++;
		m[y][x]++;
		u[i] = x;
		v[i] = y;
	};
	sort(a + 1, a + n + 1);

	long long cnt = 0;
	int j = n;
	//cout << endl;
	//for(int i = 1; i <= n; i++)
		//cout << a[i] << "  ";
	//cout << endl;
	for(int i = 1; i <= n ; i++){
		while(j > 0 && a[i] + a[j] >= p) j--;
		cnt += n - j;
		//cout << i << " " << cnt << " " << j  << endl;
	}
	for(int i = 1; i<= n; i++)
		if (a[i] * 2 >= p)
			cnt--;
	cnt /= 2;
	//truncate
	for(int i = 1; i <= n; i++)
		if (!checked[make_pair(u[i], v[i])] && !checked[make_pair(v[i], u[i])])
		{
			if (b[u[i]] + b[v[i]] >= p
					&& b[u[i]] + b[v[i]]-  m[u[i]][v[i]] < p){
				cnt --;
			}
			checked[make_pair(u[i], v[i])] = true;
			checked[make_pair(v[i], u[i])] = true;
		}
	cout << cnt;
	return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;
int n, p;
int a[100123];
int main(){
	cin >> n >> p;
	for(int i = 0; i < n; i ++){
		int x, y;
		cin >> x >> y;
		a[x]++; a[y]++;
	};
	sort(a + 1, a + n + 1);

	int cnt = 0;
	int j = n;
	//cout << endl;
	//for(int i = 1; i <= n; i++)
		//cout << a[i] << "  ";
	//cout << endl;
	for(int i = 1; i <= n ; i++){
		while(j > 0 && a[i] + a[j] >= p) j--;
		cnt += n - j;
		//cout << i << " " << cnt << " " << j  << endl;
	}
	for(int i = 1; i<= n; i++)
		if (a[i] * 2 >= p)
			cnt--;
	cnt /= 2;
	cout << cnt;
	return 0;
}


#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
typedef long long int lli;
typedef unsigned long long int ulli;
#define rep(i,a,b) for(int i=a;i<b;i++)

using namespace std;

int main ()
{
    string a,b;
    cin>>a>>b;
int n=a.size();

int j=0;
char c[n];
rep(i,0,a.size())
{
	if(a[i]!=b[i])
		{c[j]=a[i];
         j++;}
}

int p=count(c,c+n,'4');

int q=count(c,c+n,'7');

cout<<max(p,q);

	return 0;
}


#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
typedef long long int lli;
typedef unsigned long long int ulli;
#define rep(i,a,b) for(int i=a;i<b;i++)

using namespace std;
int main ()
{
    string a,b;
    cin>>a>>b;
int n=a.size();
int j=0;
char c[n];
rep(i,0,a.size())
{	if(a[i]!=b[i])
		{c[j]=a[i];
         j++;}
}
int p=count(c,c+n,'4');
int q=count(c,c+n,'7');
cout<<max(p,q);
	return 0;
}


#include <iostream>
#include <string>
using namespace std;

int main()
{
	string a, b;
	cin >> a >> b;
	int pt = 0, sp = 0;
	for (int i = 0; i < a.size(); i++) {
		if (a[i] != b[i]) {
			if (a[i] == '4')
				pt++;
			else
				sp++;
		}
	}
	int r = 0;
	if (pt > sp) {
		r = pt;
	}
	else
		r = sp;
		cout << r;
	return 0;
}


#include <iostream>
#include <string>
using namespace std;

int main()
{
	string a, b;
	cin >> a >> b;
	int p = 0;
	for (int i = 0; i < a.size(); i++)
		if (a[i] != b[i])
			p++;
	if (p & 1) {
		cout << p / 1 + 1;
	}
	else
		cout << p / 2;
	return 0;
}


#include <iostream>
#include <string>
using namespace std;

int main()
{
	string a, b;
	cin >> a >> b;
	int p = 0;
	for (int i = 0; i < a.size(); i++)
		if (a[i] != b[i])
			p++;
	if (p & 1) {
		cout << p / 2 + 1;
	}
	else
		cout << p / 2;
	return 0;
}


#include <iostream>
#include <string.h>
#include <memory.h>
using namespace std;

char a[100001]={0};
char b[100001]={0};
int main()
{
    while (~scanf("%s", a))
    {
        scanf("%s", b);
        int aonb=0, bona=0, la=strlen(a);
        for (int i=0; i<la; i++)
        {
            if (a[i]>b[i])
                aonb++;
            else if (a[i]<b[i])
                bona++;
        }
        if (aonb<bona) swap(aonb, bona);
        cout<<aonb<<endl;
        memset(a, 0, la);
        memset(b, 0, la);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
//#define int long long
const int mod = 998244353;
const int MAXN = 1e7 + 10;
inline int read() {
	char c = getchar(); int x = 0, f = 1;
	while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * f;
}
int N, n1, n2;
char s1[MAXN], s2[MAXN];
signed main() {
	scanf("%s %s", s1 + 1, s2 + 1);
	N = strlen(s1 + 1);
	for(int i = 1; i <= N; i++) {
		if(s1[i] != s2[i]) {
			if(s1[i] == '4') n1++;
			else n2++;
		}
	}
	cout << min(n1, n2) + abs(n1 - n2);
	return 0;
}
/*
1. promise the length of two sequences are same
*/


#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;

const int MAX = 10;
char a[MAX], b[MAX];

int main(void) {
    gets(a), gets(b);
    int len = strlen(a), res = 0;

    for(int i = 0; i < len - 1; ++i) {
        bool found = 0;
        for(int j = i + 1; j < len && !found; ++j)
            if(a[i] != b[i] && a[i] != a[j] && b[i] != b[j])
                swap(b[i], b[j]), ++res, found = 1;
    }
    for(int i = 0; i < len; ++i)
        if(a[i] != b[i]) ++res;

    cout << res;
    return 0;
}


#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
using namespace std;

const int MAX = 1e5 + 5;
char a[MAX], b[MAX];

int main(void) {
    scanf("%s %s", a, b);
    int len = strlen(a);

    int cnt[2]; cnt[0] = cnt[1] = 0;
    for(int i = 0; i < len; ++i)
        cnt[0] += (a[i] < b[i]), cnt[1] += (a[i] > b[i]);

    if(cnt[0] > cnt[1]) swap(cnt[0], cnt[1]);
    printf("%d", cnt[0] + cnt[1] - cnt[0]);
    return 0;
}


#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define fr(i,a,b) for(int i=a;i<b;i++)
#define frn(i,a,b) for(int i=a;i>b;i--)
#define si(x) scanf("%d",&x)
#define sll(x)  scanf("%I64d",&x)
#define pln printf("\n")
#define pi(x) printf("%d",x)
#define pll(x) printf("%I64d",x)
typedef long long ll;
ll MOD=1000000007;
ll pw(ll a,ll b){
  ll r=1;
  while(b>0){
     if(b&1){
       r=(r*a)%MOD;
        }
     b=b>>1;
     a=(a*a)%MOD;
  }
return r;
}
int dp[2][100001]={};

int main(){
 string a,b;
 cin>>a>>b;

  int a4=0,a7=0,b4=0,b7=0,op=0;
    int c[4]={0};
   fr(i,0,a.length()){
     if(a[i]!=b[i]){

        if(a[i]=='4')c[0]++;
        else if(a[i]=='7')c[1]++;
        if(b[i]=='4')c[2]++;
        else if(b[i]=='7')c[3]++;
     }
   }
  // fr(i,0,4)cout<<c[i]<" ",pln;
  sort(c,c+4);
 // fr(i,0,4)cout<<c[i]<" ",pln;
  op+=c[0];

   c[1]-=c[0];
   c[2]-=c[0];
   c[3]-=c[0];
  c[0]-=c[0];
  sort(c,c+4);
   //fr(i,0,4)cout<<c[i]<" ",pln;
  op+=c[3];
  pi(op);pln;
return 0;
}


#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define fr(i,a,b) for(int i=a;i<b;i++)
#define frn(i,a,b) for(int i=a;i>b;i--)
#define si(x) scanf("%d",&x)
#define sll(x)  scanf("%I64d",&x)
#define pln printf("\n")
#define pi(x) printf("%d",x)
#define pll(x) printf("%I64d",x)
typedef long long ll;
ll MOD=1000000007;
ll pw(ll a,ll b){
  ll r=1;
  while(b>0){
     if(b&1){
       r=(r*a)%MOD;
        }
     b=b>>1;
     a=(a*a)%MOD;
  }
return r;
}
int dp[2][100001]={};

int main(){
 string a,b;
 cin>>a>>b;

  int a4=0,a7=0,b4=0,b7=0,op=0;
    int c[4]={0};
   fr(i,0,a.length()){
     if(a[i]!=b[i]){

        if(a[i]=='4')c[0]++;
        else if(a[i]=='7')c[1]++;
        if(b[i]=='4')c[2]++;
        else if(b[i]=='7')c[3]++;
     }
   }
  // fr(i,0,4)cout<<c[i]<" ",pln;
  sort(c,c+4);
 // fr(i,0,4)cout<<c[i]<" ",pln;
  op+=c[0];

   c[1]-=c[0];
   c[2]-=c[0];
   c[3]-=c[0];
  c[0]-=c[0];
  sort(c,c+4);
   //fr(i,0,4)cout<<c[i]<" ",pln;
  op+=c[2];
  pi(op);pln;
return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define fe first
#define se second
#define mp make_pair
#define le length()
#define pb push_back
#define si size()
#define cl clear()
#define em empty()

typedef long long ll;

const int N = 1e5 + 7, inf = 1e9 + 7;
const ll mod = 1e18 + 7;

int ans;

int main() {
    #ifdef exx
//        freopen("in", "r", stdin);
    #endif
    string a, b;
    cin >> a >> b;
    int n = a.le;
    map <pair <int, int>, set <int> > m;
    for (int i = 0; i < n; i++) {
        if (a[i] != b[i]) {
            m[mp(a[i], b[i])].insert(i);
        }
    }
    for (int i = 0; i < n; i++) {
        if (a[i] != b[i]) {
            if (!m[mp(b[i], a[i])].em) {
                swap(a[i], a[*m[mp(b[i], a[i])].begin()]);
                m[mp(b[i], a[i])].erase(*m[mp(b[i], a[i])].begin());
                ans++;
            }
        }
    }
    for (int i = 0; i < n; i++) {
        if (a[i] != b[i]) {
            ans++;
        }
    }
    cout << ans;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define fe first
#define se second
#define mp make_pair
#define le length()
#define pb push_back
#define si size()
#define cl clear()
#define em empty()
#define be begin()

typedef long long ll;

const int N = 1e5 + 7, inf = 1e9 + 7;
const ll mod = 1e18 + 7;

int main() {
    #ifdef exx
//        freopen("in", "r", stdin);
    #endif
    string a, b;
    cin >> a >> b;
    int f = 0, s = 0, n = a.le;
    for (int i = 0; i < n; i++) {
        if (a[i] == '4' && b[i] == '7') {
            f++;
        }
        if (a[i] == '7' && b[i] == '4') {
            s++;
        }
    }
    cout << max(f, s);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define fe first
#define se second
#define mp make_pair
#define le length()
#define pb push_back
#define si size()
#define cl clear()

typedef long long ll;

const int N = 1e5 + 7, inf = 1e9 + 7;
const ll mod = 1e18 + 7;

int ans;

int main() {
    #ifdef exx
//        freopen("in", "r", stdin);
    #endif
    string a, b;
    cin >> a >> b;
    int n = a.le;
    set <int> f4, f7;
    for (int i = 0; i < n; i++) {
        if (a[i] != b[i]) {
            if (a[i] == '4') {
                f4.insert(i);
            } else {
                f7.insert(i);
            }
        }
    }
    for (int i = 0; i < n; i++) {
        if (a[i] != b[i]) {
            if (b[i] == '4') {
                if (!f4.empty()) {
                    swap(a[i], a[*f4.begin()]);
                    f4.erase(*f4.begin());
                } else {
                    a[i] = b[i];
                }
                ans++;
            } else {
                if (!f7.empty()) {
                    swap(a[i], a[*f7.begin()]);
                    f7.erase(*f7.begin());
                } else {
                    a[i] = b[i];
                }
                ans++;
            }
        }
    }
    for (int i = 0; i < n; i++) {
        if (a[i] != b[i]) {
            ans++;
        }
    }
    cout << ans;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define fe first
#define se second
#define mp make_pair
#define le length()
#define pb push_back
#define si size()
#define cl clear()

typedef long long ll;

const int N = 1e5 + 7, inf = 1e9 + 7;
const ll mod = 1e18 + 7;

int ans;

int main() {
    #ifdef exx
//        freopen("in", "r", stdin);
    #endif
    string a, b;
    cin >> a >> b;
    int n = a.le;
    set <int> f4, f7;
    for (int i = 0; i < n; i++) {
        if (a[i] != b[i]) {
            if (a[i] == '4') {
                f4.insert(i + 1);
            } else {
                f7.insert(i + 1);
            }
        }
    }
    for (int i = 0; i < n; i++) {
        if (a[i] != b[i]) {
            if (b[i] == '4') {
                if (*f4.begin() != 0) {
                    swap(a[i], a[*f4.begin() - 1]);
                    f4.erase(*f4.begin());
                }
                ans++;
            } else {
                if (*f7.begin() != 0) {
                    swap(a[i], a[*f7.begin() - 1]);
                    f7.erase(*f7.begin());
                }
                ans++;
            }
        }
    }
    cout << ans;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define pp pop_back
#define mp make_pair
#define F first
#define S second
#define xmax(x,y) ((x) = max((x),(y)))
#define xmin(x,y) ((x) = min((x),(y)))
#define all(x) (x).begin(),(x).end()
#define mem(x) memset(x , 0 , sizeof(x))
#define _ ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define FP(a , b , c)  for(ll (a) = (b) ; (a) < (c) ; (a++));
#define FM(a , b , c)  for(ll (a) = (b) ; (a) >= (c) ; (a--));
#define connect(a , b , c) a[b].pb(c) , a[c].pb(b)

typedef long long int ll;
typedef unsigned long long int ull;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector <ll> vl;
typedef vector <int> vi;
typedef vector <string> vs;

const ll Maxn3 = 1e3 + 10;
const ll Maxn4 = 1e4 + 10;
const ll Maxn5 = 1e5 + 10;
const ll Maxn6 = 1e6 + 10;
const ll Maxn7 = 1e7 + 10;
const ll Maxn8 = 1e8 + 10;
const ll Maxn9 = 1e9 + 10;
const ll Maxn18 = 1e18 + 10;
const ll Mod1 = 1e7 + 7;
const ll Mod2 = 1e9 + 7;
const ll LLMax = LLONG_MAX;
const ll LLMin  = LLONG_MIN;
const ll INTMax = INT_MAX;
const ll INTMin  = INT_MIN;

ll mn = LLMax , mx = LLMin;

int main()
{_
	char a[100002],b[100004];
	cin >> a >> b;
	ll l = strlen(a) , ans1 = 0 , ans2 = 0;
	for(ll i = 0 ; i < l ; i++)
	{
		if(a[i]!=b[i])
		{
			if(a[i] == '4')
				ans1++;
			else
				ans2++;
		}
	}
	return cout << max(ans1 , ans2) , 0;
}
///SAliB


//  Copyright © 2018 Diego Garcia Rodriguez del Campo. All rights reserved.
#include<bits/stdc++.h>
#define MAX 200005
#define optimiza_io cin.tie(0); ios_base::sync_with_stdio(0);
using namespace std;
typedef long long i64;

int ans, cnta, cntb;
int main()
{
    optimiza_io
    string a, b;

    cin >> a >> b;
    for( int i = 0; i < a.size(); i ++ )
        if( a[i] != b[i] )
        {
            if( b[i] == '4' )
                cnta++;
            else
                cntb++;
        }

    int t = min( cnta , cntb );
    cnta -= t;
    cntb -= t;
    cout << t + cnta + cntb << "\n";
    return 0;
}


//  Copyright © 2018 Diego Garcia Rodriguez del Campo. All rights reserved.
#define optimiza_io cin.tie(0); ios_base::sync_with_stdio(0);
using namespace std;
typedef long long i64;

int N, M;
vector < int > ar[MAX];

void changeCol( int j , int a , int b )
{
    int cnt1 = 0;
    int cnt2 = 0;
    for( int i = 1; i <= N; i ++ )
    {
        if( i & 1 )
        {
            if( ar[i][j] != a )
                cnt1++;
            if( ar[i][j] != b )
                cnt2++;
        }
        else
        {
            if( ar[i][j] != b )
                cnt1++;
            if( ar[i][j] != a )
                cnt2++;
        }
    }
    if( cnt2 < cnt1 )
        swap( a , b );
    for( int i = 1; i <= N; i ++ )
    {
        if( i & 1 )
            ar[i][j] = a;
        else
            ar[i][j] = b;
    }
}

void changeRow( int i , int a , int b )
{
    int cnt1 = 0;
    int cnt2 = 0;
    for( int j = 1; j <= M; j ++ )
    {
        if( j & 1 )
        {
            if( ar[i][j] != a )
                cnt1++;
            if( ar[i][j] != b )
                cnt2++;
        }
        else
        {
            if( ar[i][j] != b )
                cnt1++;
            if( ar[i][j] != a )
                cnt2++;
        }
    }
    if( cnt2 < cnt1 )
        swap( a , b );
    for( int j = 1; j <= M; j ++ )
    {
        if( j & 1 )
            ar[i][j] = a;
        else
            ar[i][j] = b;
    }
}

int checkCols( int a , int b , int c , int d )
{
    int ans = 0;
    for( int j = 1; j <= M; j ++ )
    {
        int cnt1 = 0;
        int cnt2 = 0;
        int n1 = a;
        int n2 = b;
        if( ! ( j & 1 ) )
            n1 = c, n2 = d;
        for( int i = 1; i <= N; i ++ )
        {
            // Row par
            if( ( i & 1 ) )
            {
                if( ar[i][j] != n1 )
                    cnt1++;
                if( ar[i][j] != n2 )
                    cnt2++;
            }
            else
            {
                if( ar[i][j] != n2 )
                    cnt1++;
                if( ar[i][j] != n1 )
                    cnt2++;
            }
        }
        ans += min( cnt1 , cnt2 );
    }

    return ans;
}

int checkRows( int a , int b , int c , int d )
{
    int ans = 0;
    for( int i = 1; i <= N; i ++ )
    {
        int cnt1 = 0;
        int cnt2 = 0;
        int n1 = a;
        int n2 = b;
        if( ! ( i & 1 ) )
            n1 = c, n2 = d;
        for( int j = 1; j <= M; j ++ )
        {
            // Col par
            if( ( j & 1 ) )
            {
                if( ar[i][j] != n1 )
                    cnt1++;
                if( ar[i][j] != n2 )
                    cnt2++;
            }
            else
            {
                if( ar[i][j] != n2 )
                    cnt1++;
                if( ar[i][j] != n1 )
                    cnt2++;
            }
        }
        ans += min( cnt1 , cnt2 );
    }

    return ans;
}

char tochar( int x )
{
    if( x == 1 )
        return 'A';
    if( x == 2 )
        return 'C';
    if( x == 3 )
        return 'G';
    if( x == 4 )
        return 'T';

}

int tonum( char x )
{
    if( x == 'A' )
        return 1;
    if( x == 'C' )
        return 2;
    if( x == 'G' )
        return 3;
    if( x == 'T' )
        return 4;
}

int main()
{
    optimiza_io
    cin >> N >> M;
    for( int i = 1; i <= N; i ++ )
    {
        ar[i].push_back( 0 );
        for( int j = 1; j <= M; j ++ )
        {
            char x;
            cin >> x;
            ar[i].push_back( tonum( x ) );
        }
    }

    int best = N*M+1;
    int bsta = -1, bstb = -1;
    bool rw = false;

    for( int a = 1; a <= 4; a ++ )
        for( int b = a + 1; b <= 4; b ++ )
            for( int c = 1; c <= 4; c ++ )
                if( c != a && c != b )
                {
                    int d = 10 - a - b - c;
                    int tmp = checkRows( a , b , c , d );
                    if( tmp < best )
                    {
                        best = tmp;
                        bsta = a;
                        bstb = b;
                        rw = 1;
                    }
                    tmp = checkCols( a , b , c , d );
                    if( tmp < best )
                    {
                        best = tmp;
                        bsta = a;
                        bstb = b;
                        rw = 0;
                    }
                }

    if( rw )
    {
        int a = bsta;
        int b = bstb;
        int c = 1;
        while( c == a or c == b )
            c++;
        int d = 10 - a - b - c;
        for( int i = 1; i <= N; i ++ )
        {
            if( i & 1 )
                changeRow( i , a , b );
            else
                changeRow( i , c , d );
        }
    }
    else
    {
        int a = bsta;
        int b = bstb;
        int c = 1;
        while( c == a or c == b )
            c++;
        int d = 10 - a - b - c;
        for( int j = 1; j <= M; j ++ )
        {
            if( j & 1 )
                changeCol( j , a , b );
            else
                changeCol( j , c , d );
        }

    }

    for( int i = 1; i <= N; i ++ )
    {
        for( int j = 1; j <= M; j ++ )
            cout << tochar( ar[i][j] );
        cout << "\n";
    }
    return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pob pop_back
#define pf push_front
#define popb pop_back()
#define popf pop_front()
#define ll long long int
#define llu long long unsigned int
#define lu long unsigned int
#define fr first
#define sc second
#define S size()
#define clr(a) memset(a, 0, sizeof(a))
#define sz(x) x.size()
#define FOR(i, x, y) for ( ll i = x; i < y;i++)
#define DEC(i, x, y) for ( ll i = x; i >= y; i--)
#define all(v) v.begin(), v.end()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
using namespace std;
typedef pair<int, int> pii;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
	int main() {
	string a,b;
	cin>>a>>b;
	ll c=0,k1=0,j=0;
	ll k=a.S;
	map<char,ll> m;
	map<char,ll> mp;
	FOR(i,0,k)
	{
		if(a[i]==b[i])c++;
		else
		{
			if(a[i]=='7')k1++;
			else j++;
		}
	}
	cout<<min(k1,j)+abs(k1-j);

	return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pob pop_back
#define pf push_front
#define popb pop_back()
#define popf pop_front()
#define ll long long int
#define llu long long unsigned int
#define lu long unsigned int
#define fr first
#define sc second
#define S size()
#define clr(a) memset(a, 0, sizeof(a))
#define sz(x) x.size()
#define FOR(i, x, y) for ( ll i = x; i < y;i++)
#define DEC(i, x, y) for ( ll i = x; i >= y; i--)
#define all(v) v.begin(), v.end()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
using namespace std;
typedef pair<int, int> pii;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
	int main() {
	string a,b;
	cin>>a>>b;
	ll c=0;
	ll k=a.S;
	map<char,ll> m;
	map<char,ll> mp;
	FOR(i,0,k)
	{
		m[a[i]]++;
		mp[b[i]]++;}
	FOR(i,0,k)
	{
		if(a[i]!=b[i])c++;
	}
	if(m['4']==mp['4']&&m['7']==mp['7']){
		cout<<c/2;
	}
	else cout<<c;

	return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pob pop_back
#define pf push_front
#define popb pop_back()
#define popf pop_front()
#define ll long long int
#define llu long long unsigned int
#define lu long unsigned int
#define fr first
#define sc second
#define S size()
#define clr(a) memset(a, 0, sizeof(a))
#define sz(x) x.size()
#define FOR(i, x, y) for ( ll i = x; i < y;i++)
#define DEC(i, x, y) for ( ll i = x; i >= y; i--)
#define all(v) v.begin(), v.end()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
using namespace std;
typedef pair<int, int> pii;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
	int main() {
	string a,b;
	cin>>a>>b;
	ll c=0;
	ll k=a.S;
	map<char,ll> m;
	map<char,ll> mp;
	FOR(i,0,k)
	{
		m[a[i]]++;
}
	cout<<min(m['4'],m['7'])+abs(m['4']-m['7']);

	return 0;
}


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

#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define eb emplace_back

typedef long long ll;
typedef pair<int,int> ii;
typedef vector< pair<int,int> > vii;
const int INF = 0x3f3f3f3f;
string s, t;

ll cont() {
    int q1 = 0;
    int q2 = 0;

    for(int i = 0; i < s.size(); i++)
        if(s[i] == '4') q1++;
    for(int i = 0; i < s.size(); i++)
        if(t[i] == '4') q2++;

    if(q1 == q2) return 0;
    ll ans = abs(q1 - q2);
    if(q1 > q2) {
        for(int i = 0; i < s.size(); i++) {
            if(q1 > q2 and s[i] == '4' and t[i] == '7') {
                q1--;
                s[i] = '7';
            }
        }
    }
    else if(q1 < q2) {
        for(int i = 0; i < s.size(); i++) {
            if(q1 < q2 and s[i] == '7' and t[i] == '4') {
                q1++;
                s[i] = '4';
            }
        }
    }
    return ans;
}

ll dist() {
    ll ans = 0;

    for(int i = 0; i < s.size(); i++)
        if(s[i] != t[i]) ans++;

    return ans/2;
}

int main() {
    ios::sync_with_stdio(false);
    cin >> s >> t;
    ll ans = 0;
    ans += cont();
    ans += dist();
    cout << ans << endl;

    return 0;
}


#include <bits/stdc++.h>
#define pb push_back
using namespace std;
int main()
{
    string s,s1;
    cin>>s;
    cin>>s1;
    vector<int>v,v1;
    for(int i=0;i<s.length();i++) {
        if(s[i]!=s1[i]) {
            if(s1[i]=='4')
                v.pb(1);
            else
                v1.pb(1);
        }
    }
    int sz1=v.size();
    int sz2=v1.size();
    int cnt=0;
    cnt+=min(sz1,sz2);
    if(sz2>sz1)
        cnt+=(sz2-sz1);
    else if(sz1>sz2)
        cnt+=(sz1-sz2);
    cout<<cnt<<endl;
    return 0;
}


#include <bits/stdc++.h>

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

#define pb push_back
#define mp make_pair

#define ll long long
#define ld long double
#define uns unsigned

#define F first
#define S second

#define sz(x) (int)x.size()
#define str(x) (int)strlen(x)
#define all(x) x.begin(), x.end()
#define sqr(x) ((x) * (x))
#define bit(x) __builtin_popcountll(x)

#define itr ::iterator

#define rt return
#define sf scanf
#define pf printf

#define forit(it,S) for(__typeof((S).begin()) it = (S).begin(); it != (S).end(); it++)
#define SABR inline ll IN(){ll x=0,ch=getchar(),f=1;while (!isdigit(ch)&&(ch!='-')&&(ch!=EOF)) ch=getchar();if (ch=='-'){f=-1;ch=getchar();}while (isdigit(ch)){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}return x*f;}inline void OUT(ll x){if (x<0) putchar('-'),x=-x;if (x>=10) OUT(x/10),putchar(x%10+'0');else putchar(x+'0');}
#define ios ios_base::sync_with_stdio(0);

#define sp system("pause");

#define Fname "bigwall"
//#define RockyBalboa
//#define TNT

using namespace std;

typedef pair <int, int> pi;
typedef pair <ll, ll> pl;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef pair <double, double> pd;

const int N = (int)1e5 + 17;
const int MX = (int) 1e6 + 17;
const int MOD = (int) 1e9 + 7;
const ll oo = LLONG_MAX;
const int INF = INT_MAX;
const ld Pi = 3.14159265358979323846264338327950288419716939937510;

const int di[4] = {-1, 0, 1, 0};
const int dj[4] = {0, 1, 0, -1};
    SABR

    void IOI2017(){
    #ifdef RockyBalboa
        freopen(Fname".in", "r", stdin);
        freopen(Fname".out", "w", stdout);
    #endif
    #ifdef TNT
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    }

    string a, b;
    int l, r, ans;
    bool c[N];
    set <int> f, s;
int main(){
    cin >> a >> b;
    for (int i = 0; i < sz(a); i++){
        if (a[i] == b[i]) c[i] = 1;
        else {
            if (a[i] == '4') f.insert(i);
            else s.insert(i);
        }
    }
    for (int i = 0; i < sz(a); i++){
        if (c[i] == 1) continue;
        else{
            if (a[i] == '4'){
                auto x = s.upper_bound(i);
                if (*x > i){
                    swap(a[i], a[*x]);
                    c[*x] = c[i] = 1;
                    ans++;
                    s.erase(x);
                    f.erase(i);
                    continue;
                }
                a[i] = b[i];
                ans++;
                c[i] = 1;
            }
            else{
                auto x = f.upper_bound(i);
                if (*x > i){
                    swap(a[i], a[*x]);
                    c[*x] = c[i] = 1;
                    ans++;
                    f.erase(x);
                    s.erase(i);
                    continue;
                }
                a[i] = b[i];
                ans++;
                c[i] = 1;
            }
        }
    }
    cout << ans;
    rt 0;
}


#include <bits/stdc++.h>

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

#define pb push_back
#define mp make_pair

#define ll long long
#define ld long double
#define uns unsigned

#define F first
#define S second

#define sz(x) (int)x.size()
#define str(x) (int)strlen(x)
#define all(x) x.begin(), x.end()
#define sqr(x) ((x) * (x))
#define bit(x) __builtin_popcountll(x)

#define itr ::iterator

#define rt return
#define sf scanf
#define pf printf

#define forit(it,S) for(__typeof((S).begin()) it = (S).begin(); it != (S).end(); it++)
#define SABR inline ll IN(){ll x=0,ch=getchar(),f=1;while (!isdigit(ch)&&(ch!='-')&&(ch!=EOF)) ch=getchar();if (ch=='-'){f=-1;ch=getchar();}while (isdigit(ch)){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}return x*f;}inline void OUT(ll x){if (x<0) putchar('-'),x=-x;if (x>=10) OUT(x/10),putchar(x%10+'0');else putchar(x+'0');}
#define ios ios_base::sync_with_stdio(0);

#define sp system("pause");

#define Fname "bigwall"
//#define RockyBalboa
//#define TNT

using namespace std;

typedef pair <int, int> pi;
typedef pair <ll, ll> pl;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef pair <double, double> pd;

const int N = (int)1e5 + 17;
const int MX = (int) 1e6 + 17;
const int MOD = (int) 1e9 + 7;
const ll oo = LLONG_MAX;
const int INF = INT_MAX;
const ld Pi = 3.14159265358979323846264338327950288419716939937510;

const int di[4] = {-1, 0, 1, 0};
const int dj[4] = {0, 1, 0, -1};
    SABR

    void IOI2017(){
    #ifdef RockyBalboa
        freopen(Fname".in", "r", stdin);
        freopen(Fname".out", "w", stdout);
    #endif
    #ifdef TNT
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    }

    string a, b;
    int l, r;
int main(){
    cin >> a >> b;
    for (int i = 0; i < sz(a); i++){
        if (a[i] != b[i]) l++;
        else r++;
    }
    cout << min(l, sz(a) - r);
    rt 0;
}


#include <bits/stdc++.h>
#define ld long double
#define int long long
#define dbgvi(x) cout << #x << " = "; for(int i = 0; i < (x.size()); ++i) cout << x[i] << " ";
using namespace std;

void solve(){
    string a, b;
    cin >> a >> b;
    int two = 0;
    int three = 0;
    int ans = 0;
    for(int i = 0; i < a.size(); ++i){
        if(a[i] != b[i]){
            if(a[i] == '4'){
                two++;
            } else {
                three++;
            }
        }
    }
    int k = min(two, three);
    ans += k;
    two -= k;
    three -= k;
    ans += two + three;
    cout << ans << "\n";
}

signed main(){
    int t = 1;
    cout << fixed << setprecision(10);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifdef DEBUG
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        //cin >> t;
    #endif
    //freopen("censored.in", "r", stdin);
    //freopen("censored.out", "w", stdout);
    while(t--){
        solve();
    }
}


#include <bits/stdc++.h>

using namespace std ;

int main() {
    string a , b ;
    cin >> a >> b ;
    int len = a.length() ;
    int cnt = 0 ;
    string x , y ;
    for(int i = 0 ; i < len ; i++) {
        if(a[i] != b[i]) {
            x.push_back(a[i]) ;
            y.push_back(b[i]) ;
        }
    }
    len = x.length() ;
    map <char , int > mp ;
    vector <int> dp[2] ;
    for(int i = 0 ; i < len ; i++) {
        mp[x[i]]++ ;
        if(x[i] == '4')
            dp[0].push_back(i) ;
        else
            dp[1].push_back(i) ;
    }
    for(int i = 0 ; i < len ; i++) {
        if(x[i] != y[i]) {
            if(x[i] == '4' && mp['7']) {
                int j = dp[1][dp[1].size() - 1] ;
                swap(x[i] , x[j]) ;
                dp[1].pop_back() ;
                mp['4']-- ;
                mp['7']-- ;
            }
            else if(x[i] == '7' && mp['4']) {
                int j = dp[0][dp[0].size() - 1] ;
                swap(x[i] , x[j]) ;
                dp[0].pop_back() ;
                mp['4']--;
                mp['7']--;
            }
            cnt++ ;
        }
    }
    cout << cnt << "\n" ;
    return 0 ;
}


#include <iostream>

using namespace std;

int main(){
    string a,b;
    cin >> a >> b;
    int fmis = 0, smis = 0;
    for(int i = 0;i < a.length();i++){
        if(a[i] != b[i]){
            if(a[i] == '4') fmis++;
            else smis++;
        }
    }
    int count = max(fmis,smis);//min exchanges plus (max - min) flips
    cout << count << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    string A,B;
    cin>>A>>B;
    int a=A.size();
    int A4=0,B4=0;
    for(int i=0;i<a;i++)
    {
        if(A[i]=='4')
            A4++;
        if(B[i]=='4')
            B4++;
    }
    int x=A4-B4;
    if(x<0)
        x*=-1;
    int counter=x;
    //cout<<x<<endl;
    if(A4>B4)
    {
        for(int i=0;counter>0;i++)
        {
            if(B[i]=='7')
            {A[i]='7';
             counter--;}
        }
        int i=0;
        while(counter>0)
        {
            if(A[i]=='4')
                {A[i]='7';
                 counter--;}
            i++;
        }
    }

    if(A4<B4)
    {
        for(int i=0;counter>0;i++)
        {
            if(A[i]=='7')
            {B[i]='7';
             counter--;}
        }
        int i=0;
        while(counter>0)
        {
            if(B[i]=='4')
                {B[i]='7';
                 counter--;}
            i++;
        }
    }
    int num=0;
    for(int i=0;i<a;i++)
    {
        if(A[i]!=B[i])
            num++;
    }
    cout<<num/2+x;
    return 0;
}


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

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const int  MOD=1000000007;
const int  INF= int(1e9);

int main()
{
    ios_base::sync_with_stdio(false);
    string a,b;
    cin>>a>>b;
    int  n =a.size();
    int four_seven,seven_four;
    four_seven=seven_four=0;
    int ok =0;
    for(int i=0;i<n;i++) {
        if(a[i] == '4' && b[i]=='7') {
            four_seven++;
        }
        else if(a[i] == '7' && b[i]=='4') {
            seven_four++;
        } else if(a[i] == b[i]) {
            ok++;
        }
    }
    cout<<max(seven_four,four_seven);

    return 0;

}


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

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const int  MOD=1000000007;
const int  INF= int(1e9);

int main()
{
    ios_base::sync_with_stdio(false);
    string a,b;
    cin>>a>>b;
    int  n =a.size();
    int four_seven,seven_four;
    four_seven=seven_four=0;
    int ok =0;
    for(int i=0;i<n;i++) {
        if(a[i] == '4' && b[i]=='7') {
            four_seven++;
        }
        else if(a[i] == '7' && b[i]=='4') {
            seven_four++;
        } else if(a[i] == b[i]) {
            ok++;
        }
    }
    int fixedPair = min(four_seven,seven_four);
    int res = fixedPair/2 + (n-fixedPair-ok);

    cout<<res;
    return 0;

}


#include<stdio.h>
#include<iostream>
#include<string.h>
#include<string>
using namespace std;
int main(){
    string a, b;
    cin>>a>>b;
    int n = a.size();
    int cnt7 = 0, cnt4 = 0;
	for(int i = 0; i < n; i++)
        if(a[i]!=b[i]){
            if(a[i] == '7')
                cnt7++;
            else
                cnt4++;
		}
    cout<<max(cnt7, cnt4)<<endl;
	return 0;
}


#include<stdio.h>
#include<string.h>
#define max(a,b) (a>b)? a:b
int main(){
    string a, b;
    cin>>a>>b;
    int n = a.size();
    int cnt7 = 0, cnt4 = 0;
	for(int i = 0; i < n; i++)
        if(a[i]!=b[i]){
            if(a[i] == '7')
                cnt7++;
            else
                cnt4++;
		}
    cout<<max(cnt7, cnt4)<<endl;
	return 0;
}


//COUNTING PATHS IN DAG DP
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <cstring>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include<random>
#include <chrono>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <time.h>
#endif
#define __ ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
// #define INF 0x7f7f7f7f
#define ull unsigned long long int
#define ui unsigned int
#define pii pair<int,int>
#define ll long long
#define ld long double
#define MSET(x,y) memset(x,y,sizeof(x))
// #define l long
#define se second
#define fi first
#define NIL 0
#define UNVISITED -1
#define EXPOLORED 0
#define mk make_pair
#define forab(i, a, b)	for (__typeof (b) i = (a) ; i <= b ; ++i)
#define rep(i, n)		forab (i, 0, (n) - 1)
#define For(i, n)		forab (i, 1, n)
#define pb push_back
#define sc(n) scanf("%d",&n)
#define NIL 0
#define pii pair<int,int>
#define eps 1e-8
#define sz(a) a.size()
#define all(x) x.begin(),x.end()
#define me(u,v,w) make_pair(w,make_pair(u,v))
#define inrange(x,y,row,col) (x>=0 && y>=0 && x<row && y<col)
#define foreach(e, x) for(__typeof(x.begin()) e = x.begin(); e != x.end(); ++ e)
#define add(a,b) (a + b >= MOD ? a+b-MOD:a+b)
#define hs(c1,c2) (256*min(c1,c2) + max(c1,c2))
const int N = 1e5+100;
const int inf = 1e9+10;
const double speed = 50.0;
int ar[N];
int ctx[110];
int a,b;
int cta[2],ctb[2];
int main(){
	__;
	string a,b,c,d;
	cin>>a>>b;
	int n = a.length();
	for(int i=0;i<n;++i){
		if(a[i]==b[i]){
			continue;
		}else{
			c += a[i];
			d += b[i];
		}
	}
	int m = c.length();
	for(int i=0;i<m;++i){
		if(c[i]=='4'){
			cta[0]++;
		}else{
			cta[1]++;
		}
	}
	for(int i=0;i<m;++i){
		if(d[i]=='4'){
			ctb[0]++;
		}else{
			ctb[1]++;
		}
	}
	int ans = min(cta[0],min(cta[1],min(ctb[0],ctb[1])));
	int fans = cta[0]+cta[1]-ans;
	cout<<fans<<endl;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define int long long

main() {
   string a, b;
   cin >> a >> b;
   int n = a.size();
   int f = 0, s = 0;
   for(int i = 0; i < n; i++)
    {
        if(a[i] != b[i])
        {
            if(a[i] == '4')
                f++;
            else
                s++;
        }
    }
    cout << min(f, s) + abs(f - s);
    return 0;
}


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

int main(){
	string a,b;
	cin>>a>>b;
	int a4b7=0, a7b4=0;

	int len = a.length();
	for(int i=0; i<len; i++){
		if(a[i]=='4' && b[i]=='7') a4b7++;
		if(a[i]=='7' && b[i]=='4') a7b4++;
	}

	int swaps = min(a4b7, a7b4);
	int replaces = max(a4b7, a7b4) - swaps;
	printf("%d",swaps+replaces);

	return 0;
}


#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define mp make_pair
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define FOR(i, start, finish, k) for(int i = start; i <= finish; i += k)

const long long MXN = 1e5 + 3;
const long long MNN = 1e3 + 1;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
const long long OO = 1e9 + 500;

typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

string s1 ,s2;
llong even, odd, d1[MXN] , ans1 , ans2;

int main(){
    ios;
    cin >> s1 >> s2 ;
    for(int j = 0 ; j < s1.size() ; j++){
        if(s1[j] == '4' && s2[j] == '7'){
            ans1++ ;
        }if(s1[j] == '7' && s2[j] == '4'){
            ans2++ ;
        }
    }cout << max(ans1 , ans2) ;
    return 0;
}


//author: zekigurbuz (Zeki Gurbuz) 2019
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<pii> vpii;
typedef queue<int> qi;
typedef map<string, int> msi;
typedef map<int, int> mii;
typedef map<int, vi> mvi;
typedef map<int, vpii> mvpii;
typedef priority_queue<int> pqi;
typedef set<int> si;

#define int ll
#define double ld
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define rsz resize
#define forn(a,b) for(int a=0;a<b;++a)
#define rep(a,b,c) for(int a=b;a<c;++a)
#define all(x) begin(x),end(x)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);

const ld PI=4*atan((ld)1);
const int MOD=1000000007;//998244353
const ll INF=0x3FFFFFFFFFFFFFFFLL;
const int N=200005;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

template<class T>void ckmin(T&a,T b){a=min(a,b);}
template<class T>void ckmax(T&a,T b){a=max(a,b);}
template<class T>using Tree=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

string Eval(bool b){return(b?"Yes":"No");}
string eval(bool b){return(b?"yes":"no");}
string EVAL(bool b){return(b?"YES":"NO");}

string a, b;
int four, seven;

void precomp() {

}

void solve(int testCaseNumber) {
	cin >> a >> b;
	forn(i, a.length()) {
		if (a[i] == '4' && b[i] != '4') four++;
		if (a[i] == '7' && b[i] != '7') seven++;
	}
	int ans = min(four, seven);
	four -= ans;
	seven -= ans;
	ans += four + seven;
	cout << ans << endl;
}

signed main(){fastio//freopen("replace.in", "r", stdin);freopen("replace.out", "w", stdout);

	precomp();
	int t = 1;
//	cin >> t;
	rep(i, 1, t + 1) solve(i);

return 0;}

//hellobig_tq//hello


#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a,b;
    int i,j,n,m,sa,c;
    while(cin>>a>>b)
    {
        c=0;
        sa=a.length();
        for(i=0;i<sa;i++)
        {

            if((a[i]!=b[i+1])||(a[i+1]!=b[i]))
            {
                if(a[i]!=b[i]){c++;
                //cout<<"IF";

                }
                else{ c;
                //cout<<"ELSE";
                }
            }
            else if(a[i]==b[i])
                    {

            continue;

                    }
            else {c++;
           // cout<<"again"<<endl;
            i++;
            }
            cout<<c<<endl;
        }
        cout<<c<<endl;
    }
    return 0;

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a,b;
    int i,j,n,m,sa,c4,c7;
    while(cin>>a>>b)
    {
        c4=0,c7=0;
        for(i=0; i<a.length(); i++)
        {
            if(a[i]!=b[i])
            {
                if(a[i]=='4')
                        c4++;
                    else c7++;
            }
        }
        cout<<max(c4,c7)<<endl;

    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a,b;
    int i,j,n,m,sa,c;
    while(cin>>a>>b)
    {
        c=0;
        sa=a.length();
        for(i=0;i<sa;i++)
        {
            if(a[i]!=b[i+1]&&a[i+1]!=b[i])
            {
                if(a[i]!=b[i])c++;
                else continue;
            }
            else {c++;
            i++;
            }
        }
        cout<<c<<endl;
    }
    return 0;

}


#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 1e5 + 7, M = 1e7, OO = 0x3f3f3f3f;
#define AC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin.sync_with_stdio(0);
int main()
{
int i,counter1=0,counter2=0,n;
string s1,s2;
cin>>s1>>s2;
n=s1.size();
for(i=0;i<n;++i){
    if(s1[i]!=s2[i]){
        if(s1[i]=='4'){
            counter1++;
        }
        else{
            counter2++;
        }
    }
}
printf("%d",max(counter1,counter2));

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int minconvert(string &a, string &b)
{
	int c47 = 0, c74 = 0;

	for(int i = 0; i < a.size(); i++)
	{
		if(a[i] == b[i])
			continue;
		if(a[i] == '4')
			c47 ++;
		else
			c74 ++;
	}

	return max(c47, c74) ;
}

int main()
{
	string a , b;
	cin >> a >> b;

	cout << minconvert(a, b) << endl;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

string a , b;

int solve(int i)
{
	if(i == 0)
		return 0;
	if(a[i] == b[i])
		return solve(i - 1);

	if(a[i] == b[i - 1] and b[i] ==  a[i - 1])
		return 1 + solve(i - 2);
	else
		return 1 + solve(i - 1);
}

int main()
{
	cin >> a >> b;
	string temp ;
	temp = "0";
	temp += a;
	a = temp;
	temp = "0";
	temp += b;
	b = temp;
	cout << solve(a.size() - 1);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

string a , b;

int solve(int i)
{
	if(i == 0)
		return 0;
	if(a[i] == b[i])
		return solve(i - 1);

	if(a[i] == b[i - 1] and b[i] ==  a[i - 1])
		return 1 + min( solve(i - 2), solve( i - 1) ) ;
	else
		return 1 + solve(i - 1);
}

int main()
{
	cin >> a >> b;
	string temp ;
	temp = "0";
	temp += a;
	a = temp;
	temp = "0";
	temp += b;
	b = temp;
	cout << solve(a.size() - 1);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

string a , b;

int solve(int i, int j)
{
	if(i == 0 or j == 0)
		return 0;

	if(a[i - 1] == b[j - 1])
		return solve(i - 1, j - 1);

	if(a[i - 1] == b[i - 2] and b[i - 1] ==  a[i - 2])
		return 1 + solve(i - 2, j - 2);
	else
		return 1 + solve( i - 1, j - 1);
}

int main()
{
	cin >> a >> b;
	cout << solve(a.size(), b.size());
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

string a , b;
int dp[int(1e5 + 1)][int(1e5 + 1)];
int solve(int i, int j)
{
	if(i == 0 or j == 0)
		return 0;
	if(dp[i][j] != -1)
		return dp[i][j];
	if(a[i - 1] == b[j - 1])
		return solve(i - 1, j - 1);

	else
		return dp[i][j] =  1 + min (solve(i - 1, j) , min( solve(i, j - 1), solve(i - 1, j - 1) ));
}

int main()
{
	cin >> a >> b;
	for(int i = 0; i <= a.size(); i++)
		for(int j = 0; j <= b.size(); j++)
			dp[i][j] = -1;
	cout << solve(a.size(), b.size());
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int minconvert(string &a, string &b)
{
	int c47 = 0, c74 = 0;

	for(int i = 0; i < a.size(); i++)
	{
		if(a[i] == b[i])
			continue;
		if(a[i] == '4')
			c47 ++;
		else
			c74 ++;
	}

	if(!c47 and !c74)
		return 0;
	if(!c47 or !c74)
		return max(c47, c74);
	else
		 min(c47, c74) ;
}

int main()
{
	string a , b;
	cin >> a >> b;

	cout << minconvert(a, b) << endl;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

string a , b;

int solve(int i, int j)
{
	if(i == 0 or j == 0)
		return 0;
	if(a[i - 1] == b[j - 1])
		return solve(i - 1, j - 1);

	else
		return  1 + min (solve(i - 1, j) , min( solve(i, j - 1), solve(i - 1, j - 1) ));
}

int main()
{
	cin >> a >> b;

	cout << solve(a.size(), b.size());
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll                   long long
#define ld                   long double
#define II                   pair<int,int>
#define III                  pair<int, II>
#define F                    first
#define S                    second
#define _mp                  make_pair
#define VI                   vector<int>
#define VII                  vector<II>
#define _f                   front
#define _b                   back
#define _pb                  push_back
#define _pf                  push_front
#define _Pb                  pop_back
#define _Pf                  pop_front
#define _all(v)              v.begin(), v.end()
#define __L                  p<<1, L, L+R>>1
#define __R                  p<<1|1, (L+R>>1)+1, R
#define LINE                 putc('\n', stdout)
#define SPACE                putc(' ' , stdout)
#define TAB                  putc('\t', stdout)
#define _out(_)              printf("%i",_)
#define __out(_,__)          printf("%i %i",_,__)
#define ___out(_,__,___)     printf("%i %i %i",_,__,___)
#define _outLL(_)            printf("%I64d",_)
#define __outLL(_,__)        printf("%I64d %I64d",_,__)
#define ___outLL(_,__,___)   printf("%I64d %I64d %I64d",_,__,___)
#define _outS(_)             printf("%s",_)
#define _outC(_)             printf("%c",_)
#define _in(_)               scanf("%i", &_)
#define __in(_,__)           scanf("%i%i",&_,&__)
#define ___in(_,__,___)      scanf("%i%i%i",&_,&__,&___)
#define _inLL(_)             scanf("%I64d", &_)
#define __inLL(_,__)         scanf("%I64d%I64d",&_,&__)
#define ___inLL(_,__,___)    scanf("%I64d%I64d%I64d",&_,&__,&___)
#define _inS(_)              scanf("%s",_)
#define __inS(_, __)         scanf("%s%s",_,__)
#define _inC(_)              scanf("%c",&_)
#define _YES                 printf("YES")
#define _NO                  printf("NO")
#define _Yes                 printf("Yes");
#define _No                  printf("No");
#define _yes                 printf("yes")
#define _no                  printf("no")
#define _for(i, n)           for(int i=0 ; i<n ; i++)
#define __for(i, j, n)       for(int i=j ; i<n ; i++)
#define FOR(i, condition)    for(int i=0 ; condition ; i++)
#define _rof(i, n)           for(int i=n ; i-- ;    )
#define __rof(i, j, n)       for(int i=n-1 ; i>=j ; i-- )
#define rm_imp(d, p)         (round(d*p)/p)
#define __lcm(a, b)          ((a*b)/__gcd(a,b))
#define _log2(x)             (31-__builtin_clz(x))
#define INF 2e8
#define Mod 1000000007
#define MAXN 200100
char s1[MAXN], s2[MAXN];
VI seven, four;
int main()
{
  __inS(s1, s2);
  int n = strlen(s1);
  _for(i, n)
         if(s1[i]=='7' && s2[i]=='4') seven._pb(i); //misplaced sevens in s1
    else if(s1[i]=='4' && s2[i]=='7') four._pb(i);
  int ans=0;
  _for(i, n)
  {
    if(s1[i]==s2[i]) continue;
    if(s1[i]=='4' && !seven.empty())
    {
      s1[i]='7';
      s1[seven.back()]='4';
      seven._Pb();
      ans++;
    }
    else if(s1[i]=='7' && !four.empty())
    {
      s1[i]='4';
      s1[four.back()]='7';
      four._Pb();
      ans++;
    }
  }
  _for(i, n)
  {
    if(s1[i]!=s2[i]) ans++;
  }
  _out(ans); LINE;
}


//ThE.EnD.AnD.ThE.BeGiNiNg ;
/*
 What made me tough
 Almost killed me
 At least that's how
 I remember the story
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
const int N = 1e7+10 ;
int n,ans ;
string a,b ;
int main(){
        ios_base::sync_with_stdio(false); cin.tie(0);
        cin >> a >> b ;
        n = a.size() ;
        for ( int i=0 ; i<n ; i++ ){
            if ( a[i]=='4' && b[i]=='7' )
                    ans++ ;
        }
        cout << ans << '\n' ;
        return 0 ;
}