#include<bits/stdc++.h>
using namespace std;
const long long MX=35,INF=1000010000;
struct Node{
long long beg,a,b;
const bool operator==(const Node &x){
return beg==x.beg&&a==x.a&&b==x.b;
}
};
Node gcd(Node x,long long k){
if(x.a==x.b) return x;
if(x.a==1) return (Node){x.beg+min(k,x.b-1),1,max(1ll,x.b-k)};
if(x.b==1) return (Node){x.beg,max(1ll,x.a-k),1};
if(x.a>x.b){
if(x.b*k<x.a) return (Node){x.beg,x.a-x.b*k,x.b};
return gcd((Node){x.beg,x.a%x.b,x.b},k-x.a/x.b);
}
else{
if(x.a*k<x.b) return (Node){x.beg+k*x.a,x.a,x.b-x.a*k};
return gcd((Node){x.beg+(x.b/x.a)*x.a,x.a,x.b%x.a},k-x.b/x.a);
}
}
long long high(Node x){
long long l=0,r=INF,mid,ans=0;
while(l<=r){
mid=(l+r)>>1;
Node now=gcd(x,mid);
if(now.a==now.b)ans=mid,r=mid-1;
else l=mid+1;
}
return ans;
}
int xx[3]={0};
inline Node toN(int a,int b,int c){
xx[0]=a,xx[1]=b,xx[2]=c;sort(xx,xx+3);
Node x;x.beg=xx[0],x.a=xx[1]-xx[0],x.b=xx[2]-xx[1];
return x;
}
signed main(){
Node x,y;long long a,b,c;
scanf("%lld%lld%lld",&a,&b,&c);x=toN(a,b,c);
scanf("%lld%lld%lld",&a,&b,&c);y=toN(a,b,c);
if(!(gcd(x,INF)==gcd(y,INF))) return puts("NO"),0;
long long high_x=high(x),high_y=high(y);
if(high_x<high_y) swap(high_x,high_y),swap(x,y);
long long sum=high_x-high_y;x=gcd(x,sum);
long long l=0,r=INF,mid,ans=0;
while(l<=r){
mid=(l+r)>>1;
Node xi=gcd(x,mid),yi=gcd(y,mid);
if(xi==yi)ans=mid,r=mid-1;
else l=mid+1;
}sum+=ans*2;
printf("YES\n%lld",sum);
return 0;
}