#include <stdio.h>
int main()
{
    int x,y,a,b,c,d,i,countA=0,countB=0,t,m,gcd,lcd;
    scanf("%d %d %d %d",&x,&y,&a,&b);
    if(x > y)
    {
        t = x;
        x = y;
        y = t;
    }
    c = x;
    d = y;
    if(x == 0) gcd = y;
    else if(y == 0) gcd = x;
    else
    {
        while(y != 0)
        {
            t = y;
            y = x%y;
            x = t;
        }
        gcd = x;
    }
    lcd = (c*d)/gcd;
    if(lcd == 1)
    {
        countB = b-a+1;
        printf("%d",countB);
    }
    else
    {
        for(i = 0; i <= b; i += lcd)
        {

            countB++;

        }
        for(i = 0; i < a; i += lcd)
        {
            countA++;
        }
        printf("%d",countB-countA);
    }
    return 0;
}

#include<stdio.h>
main()
{
     int x,y,a,b,c=0,max;
     scanf("%d%d%d%d",&x,&y,&a,&b);
     max=x>y?x:y;
     while(1)
     { if(max%x==0 && max%y==0) break;
       else max++;
      }
     c=(b/max)-((a-1)/max);
     printf("%d",c);
     return 0;
}

#include<stdio.h>

unsigned long long int gcd(unsigned long long int,unsigned long long int);
unsigned long long int lcm(unsigned long long int,unsigned long long int);

int main(){

    unsigned long long int a,b,l,x,y,i,c=0,d=0;

    scanf("%llu %llu %llu %llu",&a,&b,&x,&y);
 l=lcm(a,b);

c=y/l-(x-1)/l;
printf("%llu\n",c);
    return 0;
}
unsigned long long int gcd(unsigned long long int y,unsigned long long int  z)
    {
    if (z == 0)
       return y;
       else
       return gcd(z,y%z);
    }
unsigned long long int lcm(unsigned long long int a,unsigned long long int b)
    {
         unsigned long long int result;
         result = a*b/gcd(a,b);
    return result;}

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

int main()
{
    int l,h,lc,u,v,s,a,b,x,y,i,c=0;
    scanf("%d %d %d %d",&x,&y,&a,&b);
    if(x>y)
        {l=x;s=y;}
    else
        {l=y;s=x;}
        for(i=1;i<=s;i++)
        {
            if(x%i==0 && y%i==0)
                h=i;
        }

        lc=x*y/h;
        u=(b/lc);
        v=a/lc;
        c=u-v;
        if(a%lc==0)
            c++;
    printf("%d",c);
    return 0;
}

#include<stdio.h>

int gcd(int, int);
int lcm(int, int);

int main()
{
	int x, y, LCM;
	long int a, b, answer;
	scanf("%d %d %ld %ld", &x, &y, &a, &b);

	LCM = lcm(x, y);

	answer = b / LCM - a / LCM;

	if (a % LCM == 0) answer++;

	printf("%ld\n", answer);
	return 0;
}

int gcd(int a, int b)
{
	int temp;
	if (b <= a)
	{
		while (a % b != 0)
		{
			temp = b;
			b = a % b;
			a = temp;
		}
		return b;
	}
	else return gcd(b, a);
}

int lcm(int a, int b)
{
	return (a * b) / gcd(a, b);
}

#include <stdio.h>

int main(void) {
int h,g;
int x,y,a,b;
int i=1,count=0;
int r=1;
scanf("%d%d%d%d",&x,&y,&a,&b);

if(x>y)
{h=x;
g=y;
}
else
{
    h=y;
    g=x;
}

while(g!=0)
{
    count =h;
    h=g;
    g=count%g;
}
h=(x*y)/h;

count=(b/h)-((a-1)/h);
printf("%d",count);

    return 0;
}

#include<stdio.h>
int gcd(int a,int b)
{
	if(b==0)
		return a;
	return gcd(b,a%b);
}

int main()
{
	int x,y;
	int a,b;
	scanf("%d%d%d%d",&x,&y,&a,&b);
	int gcd1=gcd(x,y);
	int lcm=(x*y)/gcd1;
	if(a%lcm!=0)
		a=a+(lcm-a%lcm);
	b=b-b%lcm;
	if(b<a)
	{
		printf("0\n");
		return 0;
	}
	printf("%d\n",((b-a)/lcm)+1);
	return 0;
}

#include <stdio.h>

int main(void)
{
int a,b,x,y,c,d;

scanf("%d %d %d %d",&x,&y,&a,&b);
c=1;

while(c%x !=0 || c%y !=0 ) {c=c+1;}

d=(b/c - (a-1)/c) ;

printf("%d",d);

return 0;
}

#include<stdio.h>
int gcd(int a,int b)
{
	if(a%b==0)
		return b;
	else
		gcd(b,a%b);
}
int main()
{
	int x,y;
	int a,b;
	int i;
	int count=0;
	int hcf,lcm;
	scanf("%d %d %d %d",&x,&y,&a,&b);
	hcf=gcd(x,y);
	//printf("%d",hcf);
	lcm=x*y/hcf;
	a--;
	count= b/lcm-a/lcm;
	printf("%d\n",count);
	return 0;
}

#include <stdio.h>

int gcd( int a, int b);

int main()
{
	int x,y,a,b,gcdv, lcm, i, count, temp;

	scanf("%d %d %d %d",&x,&y,&a,&b);

	if( x == 1) lcm = y;
	else if( y == 1) lcm = x;
	else if( x == y) lcm = x;
	else{
	gcdv = gcd(x, y);
	lcm = x * y / gcdv;
	}

    count = 0;
    /*while(temp <= b){
        if( temp >= a) count++;
        temp = lcm * (++i);
    }*/
    count = b / lcm - a / lcm ;
    //if(b%lcm == 0) count++;
    if(a%lcm == 0) count++;

    printf("%d",count);
	return 0;
}

int gcd( int a, int b){
    int large, small, temp;

    large = small = a;
    if(a >= b) small = b;
    else large = b;

    do{
        large = large - small;
        if( large < small){
            temp = large;
            large = small;
            small = temp;
        }

    }while(large != small);
    return large;
}

#include<stdio.h>
int lcm(int a,int b)
{
    int i,p;
    for(i=1;i<=a*b;i++)
    {
        if(i%a==0 && i%b==0)
        {
            p=i;
            break;
        }
    }
    return p;
}

int main()
{
    long long int a,b,x,y,k,j,i;
    scanf("%I64d%I64d%I64d%I64d",&x,&y,&a,&b);
    k=lcm(x,y);
    if(a%k==0)
    {
        j=(b/k)-(a/k)+1;
    }
    else
    {
        j=(b/k)-(a/k);
    }
    printf("%I64d",j);
    return (0);
}

#include<stdio.h>
int main()
{
    int x,y,a,b,l,m,n,hcf,lcm;
    scanf("%d %d %d %d",&x,&y,&a,&b);
    if(x>y)
    {   l=x;
        m=y;
    }
    else
    {
        l=y;
        m=x;
    }
    n=1;
    while(1)
    {
        n=l%m;
        if(n==0)
        {
            hcf=m;
            break;
        }
        else
        {
            n=l%m;
            l=m;
            m=n;
        }
    }
    lcm=(x*y)/hcf;
    n=(b/lcm)-(a/lcm);
    if(a%lcm==0)
        n++;
    printf("%d",n);
    return 0;
}

#include<stdio.h>
int gcd (int a, int b)
{
return (b == 0) ? a : gcd (b, a%b);
}

int main()
{

    int x,y;
    long a,b;
    scanf("%d%d%ld%ld",&x,&y,&a,&b);
    long lcp = x * y / gcd(x,y);
    long output = b/lcp - (a - 1)/ lcp;
    printf("%ld\n", output);
    return 0;
}

#include <stdio.h>

int gcd(int x, int y) {
    if (y == 0)
        return x;
    return gcd(y, x % y);
}

int solve(int x, int y, int max) {
    long long lcm = 1LL * x * y;
    lcm = lcm / gcd(x, y);
    return max / lcm;
}

int main() {
    int x, y, a, b;
    scanf("%d%d%d%d", &x, &y, &a, &b);
    printf("%d", solve(x, y, b) - solve(x, y, a - 1));
    return 0;
}

#include<stdio.h>
typedef unsigned long long int ll;
ll gcd(ll a,ll b)
{
if(b==0)
return a;
return gcd(b,a%b);
}
main()
{
ll x,y,a,b,i;
scanf("%lld%lld%lld%lld",&x,&y,&a,&b);
ll gcds=x*(y/gcd(x,y));
ll start=(a/gcds);
if(a%gcds!=0)
start++;
ll end=(b/gcds);

printf("%lld\n",end-start+1);
return 0;
}

#include <stdio.h>
#include <conio.h>
#include <math.h>
#include <string.h>
#include <ctype.h>
int main ( void ){
    unsigned long int x,y,a,b,j,z,f,i;
    scanf("%d %d %d %d",&x,&y,&a,&b);
    z=findgcd(x,y);
    f=x*y/z;
    i=(a-1)/f;
    j=b/f;
    printf("%d",j-i);
    return 0;
}
int findgcd(int x,int y){
     while(x!=y){
          if(x>y)
              return findgcd(x-y,y);
          else
             return findgcd(x,y-x);
     }
     return x;
}

#include<stdio.h>
long int  gcd(long int x,long int y)
{
	if(x<y)
		return gcd(y,x);
	if(y==0)
		return x;
	return gcd(y,x%y);
}
long int lcm(long int x,long int y)
{
	long int g=gcd(x,y);
	//printf("g:%d\n",g);
	int temp= (x*y)/g;
	return temp;
}
int main()
{
	long int x,y,a,b;
	scanf("%ld%ld%ld%ld",&x,&y,&a,&b);
	long int l=lcm(x,y);
	//printf("l:%d\n",l);
	long int k,res=0,count=0,i=a;
	count=b/l-a/l;
	if(a%l==0)
		count++;
/*	for(i=l;i<=b;i+=l)
	{
		if(i>=a)
			count++;
	}

	*/
	/*	for(i=a;i<=b,i<=a+l;i++);
	for(k=i;k<=b;k+=l)
		count++;
*/	/*for (i=a;i<=b;i++)
	{
		if(i%l == 0)
		{
	//		printf("%d\n",i);
			count++;
		}
	}*/
	printf("%ld\n",count);
	return 0;
}

#include <stdio.h>

int main(void){
    int i, x, y, a, b, c=0, mcm;
    scanf("%d %d %d %d", &x, &y, &a, &b);
    for(mcm=x; mcm<=b; mcm++){
              //~ printf("%d\n",i);
        if(mcm%x == 0 && mcm%y == 0){
            break;
        }
    }

    c = b/mcm - a/mcm;
    if(a%mcm == 0){
      c++;
    }
    printf("%d\n", c);
    return 0;
}

#include <stdio.h>

int main()
{
    int x,y,a,b,h,k,r,i,p,l,j;

    scanf("%d",&x);
    scanf("%d",&y);
    scanf("%d",&a);
    scanf("%d",&b);

    l=x*y;
    for(j=1;j<=l;j++)
    {
        if(j%x==0&&j%y==0)
        {

            p=j;
            break;
        }
    }
    h=a/p;
    if(a%p==0)
        h=h-1;
    k=b/p;
    r=k-h;

    printf("%d",r);
    return 0;
}

#include<stdio.h>
int main()
{
	int i,p,x,y,a,b,c,h,q;
	scanf("%d %d %d %d",&x,&y,&a,&b);
	c=(x*y);
	for(i=1;i<=c;i++)
	{
		if(i%x==0 && i%y==0)
		{
			p=i;
			break;
		}
	}
	h=a/p;
	if(a%p==0)
		h=h-1;
	q=b/p;
	printf("%d",q-h);
	return 0;
}

#include <stdio.h>

int
gcd(int a, int b)
{
    int tmp = 0;
    while (b != 0) {
        tmp = a;
        a = b;
        b = tmp % b;
    }

    return a;
}

int
main()
{
    int x, y, a, b;
    scanf("%d %d %d %d\n", &x, &y, &a, &b);

    int lcm = (x*y)/gcd(x,y);

    int a_count = a/lcm;
    int b_count = b/lcm;
    int count = b_count - a_count;
    if (a%lcm == 0) {
        count++;
    }

    printf("%d\n", count);

    return 0;
}

#include <stdio.h>
int main ()
{
    int i,j,n,l,f,a,b,count=0;
    scanf("%d %d %d %d",&l,&f,&a,&b);
    for(i=l;i<=l*f;i=i+l) {
        if(i%f==0) {
            count=i;
            break;
        }
    }
    n=b/count-(a-1)/count;
    printf("%d\n",n);
    return 0;
}

#include<stdio.h>
int main()
{
    unsigned int a,b,c,count=0,x,y,z,i;
    scanf("%u%u%u%u",&x,&y,&a,&b);
    if(x>y)
    {
        x=x+y;
        y=x-y;
        x=x-y;
    }
    for(i=y;i<=x*y;i=i+y)
        if(i%x==0)
        {
            z=i;
            break;
        }
    count=b/z;
    count=count-((a-1)/z);
    printf("%u",count);
    return 0;
}

#include<stdio.h>
#include<math.h>
#define MAX(a,b) (a>b)?a:b
int main()
{
	int i,d,a,b,x,y,sum=0,j;
	scanf(" %d %d %d %d",&x,&y,&a,&b);
	d=MAX(x,y);
	for(;;d++)
		if(d%x==0 && d%y==0) break;
	for(i=a;i<=b;i++)
		if(!(i%d)) break;
	for(j=b;j>=a;j--)
		if(!(j%d)) break;
	if(j>=i) sum=(j-i)/d+1;
	printf("%d",sum);
	return 0;
}

#include<stdio.h>
int main()
{
    int x,y,c=0,big;
    long long int a,b,i,q=-1,lcm;
    scanf("%d%d%I64d%I64d",&x,&y,&a,&b);
    if(x>y)
        big=x;
    else
        big=y;
   //     printf("%d\n",big);
    for(i=big;;i++)
   {
       if(i%x==0 && i%y==0)
    {
        lcm=i;
        break;

    }
   }
  //printf("%I64d ",lcm);
   for(i=a;i<=b;i++)
   {
       if(i%lcm==0)
        {  // printf("%I64d",b-i);
           q=(b-i)/lcm;
           break;
       }
   }

    printf("%I64d",q+1);

   return 0;
}

#include<stdio.h>
int divisor(int x, int y)
{
	int c = y;
	while(x % y){
		c = x % y;
		x = y;
		y = c;
	}
	return c;
}
int main()
{
	int x, y, c, sum;
	long long a, b;
	scanf("%d%d%I64d%I64d", &x, &y, &a, &b);
	c = x*y/divisor(x,y);
	sum = (b/c - (a-1)/c);
	printf("%d\n", sum);
	return 0;
}

#include <stdio.h>

#define int long long

int gcd(int x, int y)
{
	return (y ? gcd(y, x % y) : x);
}
int lcm(int x, int y)
{
	return (x / gcd(x, y) * y);
}

signed main(void)
{
	int x, y, c;
	int a, b;
	int i;

	scanf("%lld %lld %lld %lld", &x, &y, &a, &b);
	x = lcm(x, y);

	if (a != 1){
		printf("%I64d\n", b / x - (a - 1) / x);
	}
	else {
		printf("%I64d\n", b / x);
	}

	return (0);
}

#include<stdio.h>
int main()
{
    int x,y,a,b;
    scanf("%d%d%d%d",&x,&y,&a,&b);
    int i=1;
    int count=0;
    int add=(x*y)/lcm(x,y);
    while(a%add!=0)
    a++;
    while(b%add!=0)
        b--;
     count=(b-a)/add+1;
    printf("%d",count);
    return 0;
}

int lcm(int a,int b)
{
    if(b==0)
        return a;
    if(a<b)
    {
        int temp=a;
        a=b;
        b=temp;
    }
   return lcm(b,a%b);

}

#include<stdio.h>
int hcf(int a,int b)
{
	if(b==0)
		return a;
	else
		hcf(b,a%b);
}
int main()
{
	int l,k,j,i;
	int x,y,a,b;
	scanf("%d%d%d%d",&x,&y,&a,&b);
	int lcm=(x*y)/hcf(x,y);
	int num=0;
//	printf("%d    ",lcm);
//	num=(b-a)/lcm;
//	printf("%d   ",num);
	int g=b/lcm;
	int h=a/lcm;
	num=g-h;
	if(a%lcm==0)
		num++;
	printf("%d\n",num);
	return 0;
}

#include <stdio.h>
#include <stdlib.h>
int main()
{
    long long int x,y,w,r,h,j,a,b,gcd,lcm,i;
    scanf("%I64d%I64d%I64d%I64d",&x,&y,&a,&b);
    w=x;
    r=y;
    if(x>y) {
    while(y) {
        gcd=x%y;
        x=y;
        y=gcd;
    }
    lcm=(w*r)/x;
    }
    else {
        while(x) {
            gcd=y%x;
            y=x;
            x=gcd;
        }
        lcm=(w*r)/y;
    }

    h=b/lcm;
    i=(a-1)/lcm;

    printf("%I64d",h-i);

    return 0;
}

#include <stdio.h>

int main (int args, char** argv) {
	int x, y, a, b;
	int gcd, lcm, quotient, remainder, divisor;
	int count, highest, lowest, deduct;

// Scan inputs
	while (scanf("%d %d %d %d", &x, &y, &a, &b) != EOF) {

	// Euclid's Algorithm for gcd(x,y)
		if ( x <= y ) {
			quotient = y;
			divisor = x;
		}
		else {
			quotient = x;
			divisor = y;
		}
		while ( (remainder = (quotient%divisor)) != 0 ) {
			quotient = divisor;
			divisor = remainder;
		}
		gcd = divisor;
	// Lowest Common Multiple - LCM
		lcm = (x*y)/gcd;
		//printf ("x: %d, y: %d, a: %d, b: %d\n",x,y,a,b);
		//printf ("GCD: %d\tLCM: %d\n",gcd,lcm);
	// Total Count
		if ( a >= b ) {
			highest = a;
			lowest = b;
		}
		else {
			highest = b;
			lowest = a;
		}
		count = highest/lcm;

		deduct = (lowest-1)/lcm;
		count -= deduct;

	// Print
		printf("%d\n", count);
	}
	return 0;
}

#include<stdio.h>
int main()
{
    //freopen("in.txt","r",stdin);
    int x,y,a,b,n,m,r,t=0;
    scanf("%d%d%d%d",&n,&m,&a,&b);
    x=n;
    y=m;
    if(x<y)
    {
        r=x;
        x=y;
        y=r;
    }
    while(y)
    {
        r=x%y;
        x=y;
        y=r;
    }
    x=n*m/x;
    if((a/x)*x!=a)
        a=a/x+1;
    else
        a=a/x;
    b=b/x;
    printf("%d\n",b-a+1);
    return 0;
}

#include<stdio.h>
#include<math.h>
#include<string.h>
int main()
{
    int a, b, x, y, i, j, k, hold, p;
    scanf("%d %d %d %d", &a, &b, &x, &y);
    hold = a*b;
    for(i=1;i<=hold;i++){
        if(i%a==0 && i%b==0){
            p = i;
            break;
        }
    }

    j = x/p;
    if(x%p==0){
        --j;
    }
    k = y/p;
    printf("%d", k-j);
    return 0;
}

#include<stdio.h>
   long gcd(long x,long y);
  int main()
   {
    long x,y,l,p,q;
   long  a,b;
   scanf("%ld%ld%ld%ld",&x,&y,&a,&b);
   l=(x*y)/gcd(x,y);
  p=a/l;q=b/l;
 if(a%l==0)
  q++;
  printf("%ld",q-p);
  return(0);
  }
 long gcd(long x,long y)
  {
      if(y>x)
          return gcd(y,x);
       else if(y==0)
           return x;
        else
       return gcd(y,x%y);
  }

#include <stdio.h>
long long int gcd(long long int, long long int);
int main(){
    long long int x,y,a,b;
    scanf("%lli %lli %lli %lli", &x,&y,&a,&b);
    while (b%x!=0 || b%y!=0 ){
        b--;
    }
    while (a%x!=0 || a%y!=0 ){
        a++;
    }

    printf("%lli", (b-a)/((x*y)/gcd(x,y))+1);

    return 0;
}

long long int gcd (long long int x, long long int y){
while (y!=0 && x!=0){
    if (y<x){
        x-=y;
    }else{
        y-=x;
    }
}
if(x==0){
        return y;
}else{

    return x;
}

}

#include <stdio.h>
// :)
long long int gcd(long long int, long long int);
int main(){
    long long int x,y,a,b;
    scanf("%lli %lli %lli %lli", &x,&y,&a,&b);
    while (b%x!=0 || b%y!=0 ){
        b--;
    }
    while (a%x!=0 || a%y!=0 ){
        a++;
    }

    printf("%lli", (b-a)/((x*y)/gcd(x,y))+1);

    return 0;
}

long long int gcd (long long int x, long long int y){
while (y!=0 && x!=0){
    if (y<x){
        x-=y;
    }else{
        y-=x;
    }
}
if(x==0){
        return y;
}else{

    return x;
}

}

#include<stdio.h>
#include<math.h>
long long gcd(long long a, long long b)
{
    long long temp;
    while(b)
    {
        temp=a%b;
        a=b;
        b=temp;
    }
    return a;
}
int main ()
{
    long long x,y,a,b,p,q,ans;
    scanf("%lld %lld %lld %lld",&x,&y,&b,&a);
    p=(x*y)/gcd(x,y);
    ans=(a/p)-(b/p);
    if((double)b/p==b/p)
         ans++;
    printf("%lld\n",ans);
    return 0;
}

#include <stdio.h>
#include <stdlib.h>
int gcd(a, b)
{
    int m, i, ans;
    m = (a>b)?b:a;
    for(i = m; i >= 1; i--){
        if(a%i==0 &&  b%i==0){
            ans =  i;
            break;
        }
    }
    return (a*b)/ans;
}

int main()
{
    int x, y, a, b, i, p;
    scanf("%d%d%d%d", &x, &y, &a, &b);
    p = gcd(x, y);
  //  printf("%d\n", p);
  if(a%p==0 && b%p!=0){
    printf("%d", (b/p)-(a/p)+1 );
  }
  else if(a%p!=0 && b%p==0){
     printf("%d",  (b/p)-(a/p));
  }
    else if(a%p==0 && b%p==0){
        printf("%d", (b/p)-(a/p)+1);
    }
    else{
        printf("%d", (b/p)-(a/p));
    }
    return 0;
}

#include<stdio.h>
#include<stdlib.h>
int x,y,a,b;
int k;
int gcd(int x,int y)
{
	if (x%y==0) return y;
	return gcd(y,x%y);
}
int main()
{
	scanf("%d%d%d%d",&x,&y,&a,&b);
	k=x*y;
	k/=gcd(x,y);
	printf("%d",b/k-(a-1)/k);
	return 0;
}

#include <stdio.h>
#ifdef LOCAL
#include <time.h>
#endif
int gcd(int big, int small)
{
    int tmp = 1;
    while(tmp > 0)
    {
        tmp = big % small;
        big = small, small = tmp;
    }
    return big;
}
void swap(int *first, int *second)
{
    int tmp;
    tmp = *first;
    *first = *second;
    *second = tmp;
}
int main()
{
#ifdef LOCAL
	freopen("test.txt", "r", stdin);
#endif
    int x, y, a, b;
    scanf("%d%d%d%d", &x, &y, &a, &b);
    if(y > x)
        swap(&x, &y);
    int m = (x * y) / gcd(x, y);
    int start;
    if(a % m == 0)
        start = a/m;
    else
        start = a/m+1;
    printf("%d\n", b/m-start+1);
#ifdef LOCAL
    printf("It took %f seconds.\n", ((double)clock())/CLOCKS_PER_SEC);
#endif
}

#include<stdio.h>
int main()
{
    int i,j,r=0;
    int x,y,a,b;
    scanf("%d %d %d %d",&x,&y,&a,&b);
    for(i=y;i<=x*y;i++){
        if(i%y==0&&i%x==0){
              break;
        }
    }
 int k=((b/i)-((a-1)/i));
  printf("%d ",k);
    return 0;
}

#include<stdio.h>
int Eucilid(int a,int b)
{
    if(b==0)
    return a;

    return Eucilid(b,a%b);
}
int main()
{
    int x,y,a,b,c,lcm;
    scanf("%d%d%d%d",&x,&y,&a,&b);
    Eucilid(a,b);
    lcm=(x*y)/Eucilid(x,y);
    int div=b/lcm - (a-1)/lcm;
    printf("%d",div);

}

#include<stdio.h>
int lcm(long long int a,long long int b)
{
    int i,c,A=a,B=b;
    for( ; b>0;)
    {
        c=a%b;
        a=b;
        b=c;
    }
    c=(A*B)/a;
    return c;
}
int main()
{
    long long int a,b,c,d,i,j;
    scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
    i=lcm(a,b);
    printf("%lld\n",d/i-(c-1)/i);
    return 0;
}

#include<stdio.h>
int main()
{
    long long int x,y,a,b,i,k,l=0,rem,j,m,n;
    scanf("%lld %lld %lld %lld",&x,&y,&a,&b);
    m=x;
    n=y;
    while(y!=0)
    {
        rem=x%y;
        x=y;
        y=rem;
    }
    k=(m*n)/x;
    if(a%k!=0)
    {
        j=a+k-a%k;
        if(j<=b)
        {
            l=1;
        }
    }
    else
    {
        j=a;
        l=1;
    }
    i=b-j;
    if(i<=0)
    {
        l=l;
    }
    else
    {
        l=l+(i/k);
    }
    printf("%lld\n",l);
    return 0;
}

#include<stdio.h>
int main()
{
    int i,a,t,b,x,y,count=0,tmp;
    scanf("%d%d%d%d",&x,&y,&a,&b);
    for(i=1; i<=(x*y); i++)
    {
        if(i%x==0&&i%y==0)
        {
            t=i;
            break;
        }
    }
    count=(b/t)-(a/t);
    if(a%t==0)
        count++;
    printf("%d",count);
    return 0;
}

#include <stdio.h>

int main(void)
{
int a,b,x,y,c,d;

scanf("%d %d %d %d",&x,&y,&a,&b);
c=1;

while(c%x !=0 || c%y !=0 ) {c=c+1;}

d=(b/c - (a-1)/c) ;

printf("%d",d);

return 0;
}

#include <stdio.h>
int main()
{
    int x,y,a,b,lcm,m,i,j=0,temp,ans=0;
    scanf("%d %d %d %d",&x,&y,&a,&b);
    m=x*y;
    while(y>0){
        temp=y;
        y=x%y;
        x=temp;
    }
    lcm=m/x;
    for(i=a;i<=b;i++){
        if(i%lcm==0){
            j=i;
            break;
        }
    }
    if(j>0) ans=(b-j)/lcm+1;
    printf("%d",ans);
    return 0;
}

#include<stdio.h>
int main()
{
    int x,y,a,b,max,lcm,i,ans,d;
    scanf("%d %d %d %d",&x,&y,&a,&b);
    max=y;
    if(x>=y)
    max=x;
    lcm=x*y;
    for(i=max;i<=x*y;i++)
    {
        if(i%x==0&&i%y==0)
        {
        lcm=i;
        break;
        }
    }
    if(a%lcm==0)
    ans=((b-(b%lcm))/lcm)-((a+(a%lcm))/lcm)+1;
    else
    ans=((b-(b%lcm))/lcm)-((a+lcm-(a%lcm))/lcm)+1;
    printf("%d",ans);
    return 0;
}

#include <stdio.h>

int hcf (int,int);

int x,y;
long a,b;
int main()
{

int i;
scanf("%d%d%ld%ld",&x,&y,&a,&b);
int lcm,count=0;
lcm=(x*y)/hcf(x,y);
long z;
if(a%lcm==0)
z=(a/lcm) -1;
else z=(a/lcm);

count=(b/lcm)-z;

printf("%d\n",count);
return 0;
}

int hcf (int p,int q)
{
if(p==q)
return p;
else if(p>q)
hcf (p-q,q);
else
hcf(p,q-p);
}

#include<stdio.h>
long long int lcm1(long long int,long long int);
int main()
{
    long long int x,y;
    long long int a,b,lcm,n,j;
    scanf("%I64d %I64d %I64d %I64d",&x,&y,&a,&b);
    lcm=(x*y)/lcm1(x,y);
    for(j=a;j<=b;j++)
    {
        if(j%x==0&&j%y==0)
            break;
    }
    n=(b-j)/lcm;
    if(j!=b+1)
    n++;
    printf("%I64d\n",n);
    return(0);
}
long long int lcm1(long long int x,long long int y)
{
    if(y==0)
        return((long long int)x);
    lcm1(y,x%y);
}

#include <stdio.h>
#include <inttypes.h>
int main()
{
	int64_t a,b,i,count=0,base,start,end;
	int x,y;
	scanf("%d %d %"PRId64" %"PRId64" ",&x,&y,&a,&b);
	base = lcm(x,y);
	//printf("lcm = %d\n",base);

	if((a/base)*base < a)
		start = (a/base + 1)*base;
	else
		start = (a/base)*base;

	if((b/base)*base <= b)
		end = (b/base)*base;
	else
		end = (b/base - 1)*base;

	count = (end-start)/base;

	printf("%"PRId64"",count+1);
	return 0;
}

int lcm(int x, int y)
{
	int i;
	for(i=max(x,y);i<=x*y;i++)
	{
		if(i%x==0 && i%y==0)
			return i;
	}
}

int max(int x,int y)
{
	if(x>y)
		return x;
	else
		return y;
}

#include <stdio.h>
int gcd(int x,int y)
{
    return y!=0?gcd(y,x%y):x;
}
int main()
{
    int a,b,x,y,i,j,k;
    __int64 sum;
    while(scanf("%d%d%d%d",&x,&y,&a,&b)!=EOF)
    {
        sum=x*y/gcd(x,y);k=0;
        k=b/sum-a/sum;
        if(a%sum==0)
        k++;
        printf("%d\n",k);
    }
    return 0;
}

#include<stdio.h>

long int getGCD(int a,int b);

int main(){
    int i,x,y;
    long int a,b,j;
    scanf("%d %d %lu %lu",&x,&y,&a,&b);
    long int lcm,gcd;
    if(x<y){
        gcd=getGCD(x,y);
    }
    else{
        gcd=getGCD(y,x);
    }
    lcm=(x*y)/gcd;
    long int first,last;
    j=a%lcm;
    if(j==0){
        first=a;
    }
    else{
        first=a+lcm-j;
    }
    j=b%lcm;
    last=b-j;
    long int answer=((last-first)/lcm)+1;
    printf("%lu\n",answer);
    return 0;
}

long int getGCD(int a,int b){
    if(b%a==0){
        return a;
    }
    else{
        return getGCD(b%a,a);
    }
}

/*
 * FCTRL.c
 *
 *  Created on: 24 A�u 2014
 *      Author: KT
 */

#include <stdio.h>
 int gcd( int a, int b){
	if(b==0){
		return a;
	}
	return gcd(b,a%b);
}
int main(void){
	int x,y;
unsigned long long int a,b;
scanf("%d %d %I64d %I64d",&x,&y,&a,&b);
int k=(x*y)/gcd(x,y);
while(a%k!=0){
	a++;
}
while(b%k!=0){
	b--;
}
printf("%I64d",((b/k)-(a/k)+1));
return 0;
}

#include <stdio.h>
int gcd (int x, int y);
int main(void){
	int x,y,a,b,i=1;
	int cou,sum;
	scanf("%d%d%d%d",&x,&y,&a,&b);
	cou=x/gcd(x,y)*y;
	sum=b/cou-a/cou;
	if (a%cou==0)
		sum++;
	printf("%d",sum);
	return 0;
}

int gcd (int x, int y){
	int r;
	while(1){
		r=x%y;
		if (r==0)
			break;
		x=y;
		y=r;
	}
	return y;
}

#include <stdio.h>
int gcd(int a, int b);
int main(void){
	int x,y,a,b,count,lcm;
	scanf("%d %d %d %d", &x, &y, &a, &b);

	lcm = (x * y)/gcd(x,y);

	count = b/lcm;
	if(lcm >= a)
    	printf("%d\n", count);

	if(lcm < a){
		if(a % lcm == 0)
		    printf("%d\n", count-(a/lcm)+1);
		else
		    printf("%d\n", count-(a/lcm));
	}

	return 0;
}

int gcd(int a, int b){
	if(b == 0)
	    return a;
	else
	    return gcd(b, a%b);
}

#include<stdio.h>
long int gcd(long int,long int);
long int sub(long int , long int );
int main()
{
	long int x,y,a,b,count=0,temp,i,k,m;

	scanf("%lu %lu %lu %lu",&x,&y,&a,&b);
	temp = x*y;

	temp = temp/gcd(x,y);

	if(a>=b)
	{
		k=a/temp;
		m=(b-1)/temp;
		k=k-m;
	}
	else
	{
		k=b/temp;
		m=(a-1)/temp;
		k=k-m;
	}

	printf("%lu\n",k);
	return 0;

}
long int gcd (long int a,long int b)
{
	long int i;
	if(b<=0)
		return a;
	else{
		i=gcd(b,sub(a,b));
		return i;
	}

}
long int sub(long int a, long int b)
{
	if(a>=b)
		return(a-b);
	else
		return(b-a);

}

#include<stdio.h>
int gcd(int a,int b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}

int main()
{
    int a,b,x,y,lcm;
    scanf("%d %d %d %d",&a,&b,&x,&y);
    lcm=a*b/gcd(a,b);
    printf("%d\n",y/lcm-(x-1)/lcm);
    return 0;
}

#include<stdio.h>
lcm(int n1,int n2)
{
    int temp1=n1; int temp2=n2;
    if(temp1==temp2)
    {
        return n1;
    }
    while(temp1!=temp2)
    {
         if(temp1>temp2)
                  temp1-=temp2;
         else
         temp2-=temp1;
    }
    return (n1*n2)/temp1;
}
int main()
{
    long a,b,c,d=0,i,x,y,e;
    scanf("%ld%ld%ld%ld",&x,&y,&a,&b);
    if(x==y)
    {
        if(x==a)
        {
            d=b/x;

        }
        else
        d=(b/x)-a+1;
        goto z;
    }
    if(a==1)
    {
        d=(b/lcm(x,y));
        goto z;
    }
    if(a%x==0)
    {
        c=a/x;
    for(i=a;i<=b;i=c*x)
    {
        if(i%y==0)
            {
                d++;
            }
            c++;
    }
    }
    else
    {
        e=a+x-(a%x);
        if(y==1)
        {
            d=(b/e)-a+1;
            goto z;
        }
        c=e/x;
        for(i=e;i<=b;i=c*x)
        {
        if(i%y==0)
            {
                d++;
            }
            c++;
        }
    }
    z:
    printf("%ld",d);
    return 0;
}

#include<stdio.h>
long int gcd(int a,int b)
{
    int c;
    while(a!=b)
    {
    if(a>b)
    a=a-b;
    else
    {
        c=b;
        b=a;
        a=c;
    }}
    return a;

}

main()
{
    long int g,j,a,b,x,y,i,p,cnt=0;
    scanf("%d%d%d%d",&a,&b,&x,&y);
    g=gcd(a,b);
    p=a*b;
    g=p/g;
    i=x;
    j=y;
    while(i%g!=0&&i<=y)
    {
        i++;
    }
    while(j%g!=0&&j>=x)
    {
        j--;
    }
    p=j-i;
    cnt=p/g;
    if(cnt==0&&i!=j)
    {
        {
            printf("0");
            exit(0);
        }
    }
    printf("%d",cnt+1);
    return 0;
}

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

int gcd(int a, int b) {
	if(b == 0) return a;
	return gcd(b, a%b);
}

int lcm(int a, int b) {
	return (a/gcd(a,b))*b;
}

int main() {
	int x, y, a, b;

	scanf("%d %d %d %d", &x, &y, &a, &b);

	printf("%d", b/lcm(x,y) - a/lcm(x,y) + (a%lcm(x, y) == 0 ? 1 : 0));

	return 0;
}

#include<stdio.h>

int main()
{
    int x,y,ans=0;
    long long int a,b,i=1;
    scanf("%d%d%I64d%I64d",&x,&y,&a,&b);
    int t;
    while(i%x!=0||i%y!=0)
        i++;
    t=i;
    if(a%t==0)
        ans=b/t - a/t+1;
    else
        ans=b/t - a/t;
    printf("%d",ans);

    return 0;
}

#include <stdio.h>
int getit(int x, int y, int b)
{
    int i = 0, smaller = x < y? x:y, bigger = x > y?x:y;
    for(i = bigger; i < b; i+=bigger)
        if(i % smaller == 0)
                return i;
    return x*y;
}
int main()
{
	long long x = 0, y = 0, a = 0, b = 0, i = 0, total = 0, wanted = 0;
	scanf("%d%d%d%d",&x,&y,&a,&b);
	wanted = y % x == 0? y:getit(x,y,b);

    for(i = a; i <= b; i++)
        if(i % wanted == 0)
        {
            a = i;
            break;
        }
    if(a == b && wanted != a)
        printf("0");
    else
        printf("%d",1+(b-a)/wanted);
}

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

int main()
{
    int x, y;
    long long int a,b,i,j,k,count =0 ;
    scanf("%d%d%I64d%I64d",&x,&y,&a,&b);
    j = x<y?x:y;
    k = x>y?x:y;
    for(i = a;i <= b;i += j)
    {
        if(i%k==0)count++;
    }
    printf("%I64d",count);
    return 0;
}

#include <stdio.h>

typedef long long int int64;

int main(void)
{
	int x, y;
	int64 a, b;

	scanf("%d %d %lld %lld", &x, &y, &a, &b);
	x *= y;
	printf("%I64d\n", (b + a) / x);
	return (0);
}

#include<stdio.h>
int f1(int n,int m)
{
if(m==0)
return n;
return f1(m,n%m);
}

main()
{
    int x,y,a,b,ans,f,g;
    scanf("%d %d %d %d",&x,&y,&a,&b);
    g=f1(x,y);
    f=(x*y)/g;
//  printf("%d %d\n",f,g);
    ans=b/f-a/f;
    if(a%g==0)
    ans++;
    printf("%d",ans);
//  scanf("%d",&x);
    return 0;
}

#include<stdio.h>
int main()
{
    int i,a,t,b,x,y,count=0,tmp;
    scanf("%d%d%d%d",&x,&y,&a,&b);
    for(i=2; i<=(a*b); i++)
    {
        if(i%x==0&&i%y==0)
        {
            t=i;
            break;
        }
    }
    count=(b/t)-(a/t);
    if(a%t==0)
        count++;
    printf("%d",count);
    return 0;
}

#include <stdio.h>
int gcd(int a, int b);
int main(void){
	int x,y,a,b,i,count = 0,lcm;
	scanf("%d %d %d %d", &x, &y, &a, &b);

	lcm = (x * y) / gcd(x,y);

	for(i = 1; ; i++){
		x = i * lcm;
		if(x >= a && x <= b)
			count++;

		if(x > b)
			break;
	}

	printf("%d\n", count);
	return 0;
}

int gcd(int a, int b){
	if(b == 0)
		return a;

	else
		return (b , b/a);
}

#include<stdio.h>
#include<math.h>
#include<string.h>

int cmmc(int num1, int num2) {

    int resto, a, b;

    a = num1;
    b = num2;

    do {
        resto = a % b;

        a = b;
        b = resto;

    } while (resto != 0);

    return ( num1 * num2) / a;
}

int main(){
  int x,y,a,b;
  int mmc, count=0, diff;
  scanf("%d %d %d %d", &x, &y, &a, &b);
  mmc= cmmc(x,y);
  if(a/mmc >=0 && a/mmc <=1){
      a=mmc;
  }else if(a %mmc!=0){
      a=((a/mmc)*mmc)+mmc;
  }
  diff=b-a;
  if(diff!=0){
    count=diff/mmc;
    if(count!=0 || (a%mmc==0))
        count++;
 }else{
     if(a%x==0){
         count=1;
     }
 }
  printf("%d\n", count);
  return 0;

}

#include <stdio.h>
int main()
{
    int x,y,a,b,c,d,i,count=0,t,m,gcd;
    scanf("%d %d %d %d",&x,&y,&a,&b);
    if(x > y)
    {
        t = x;
        x = y;
        y = t;
    }
    c = x;
    d = y;
    if(x == 0) gcd = y;
    else if(y == 0) gcd = x;
    else
    {
        while(y != 0)
        {
            t = y;
            y = x%y;
            x = t;
        }
        gcd = x;
    }
    i = 1;
    while(gcd <=x )
    {
        gcd *= i;
        i++;
    }
    printf("%d",i);
    return 0;
}

#include<stdio.h>
long int gcd(int a,int b)
{
    int c;
    while(a!=b)
    {
    if(a>b)
    a=a-b;
    else
    {
        c=b;
        b=a;
        a=c;
    }}
    return a;

}

main()
{
    long int g,j,a,b,x,y,i,p,cnt=0;
    scanf("%d%d%d%d",&a,&b,&x,&y);
    g=gcd(a,b);
    p=a*b;
    g=p/g;
    i=x;
    j=y;
    while(i%g!=0&&i<=y)
    {
        i++;
    }
    while(y%g!=0&&j>=x)
    {
        y--;
    }
    if(x==y&&x%g!=0)
    {
        printf("0");
        exit(0);
    }
    p=j-i;
    cnt=p/g;
    printf("%d",cnt+1);
    return 0;
}

#include <stdio.h>

long long int lcm(long long int a,long long int b,long long int x)
{
    if(a%b)
        lcm(a+x,b,x);
    else
        return a;
}
int main()
{
    long long p,q,r,s,common,i,count=0,low,m,n,range;
    scanf("%I64d %I64d %I64d %I64d",&p,&q,&r,&s);
    if(p>q)
        common=lcm(p,q,p);
    else
        common=lcm(q,p,q);
    //printf("common:%I64d\n",common);
    if(r%common==0)
    {
        low=r;
    }
    else
    {
        m=r/common;
        low=(m+1)*common;
    }
    range=s-low;
    count=range/common;
    //for(i=low; i<=s; i+=common)
    //{
        //count++;
    //}
    printf("%I64d",count+1);
    return 0;
}

#include<stdio.h>
int main()
{
    int x,y,a,b,max,lcm,i,ans,d;
    scanf("%d %d %d %d",&x,&y,&a,&b);
    max=y;
    if(x>=y)
    max=x;
    lcm=x*y;
    for(i=max;i<=x*y;i++)
    {
        if(i%x==0&&i%y==0)
        {
        lcm=i;
        break;
        }
    }
    ans=(b/lcm)-(a/lcm);
    if(lcm%a==0||lcm%b==0)
    ans+=1;
    if(lcm%a==0&&lcm%b==0)
    ans=ans-1;
    printf("%d",ans);
    return 0;
}

#include<stdio.h>
int arr[1000001],ar[1000001];
int main()
{
	int x,y,a,b;
	int ans=0,k1=0,k2=0;
	int i,max,min;
	scanf("%d%d%d%d",&x,&y,&a,&b);
	if(x<y)
	{
		max=y;
		min=x;
	}
	else
	{
		max=x;
		min=y;
	}

	for(i=x;i<=b;i+=min)
	{
		if(i>=a)
		{
//			printf("%d ",i);
			arr[k1]=i;
			k1++;
		}
	}
//	printf("\n");
	for(i=y;i<=b;i+=max)
	{
		while(arr[k2]<i)
		{
			k2++;
		}
		if(arr[k2]==i)
		{
//			printf("%d ",i);
			ans++;
		}
	}
//	printf("\n");
	printf("%d\n",ans);
	return 0;
}

#include <stdio.h>
int getit(int x, int y, int b)
{
    int i = 0, smaller = x < y? x:y, bigger = x > y?x:y;
    for(i = bigger*2; i < b; i+=bigger)
        if(i % x == 0)
                return i;
    return x*y;
}
int main()
{
	long long x = 0, y = 0, a = 0, b = 0, i = 0, total = 0, wanted = 0;
	scanf("%d%d%d%d",&x,&y,&a,&b);
	wanted = x == y? x:getit(x,y,b);
    for(i = a; i <= b; i++)
        if(i % wanted == 0)
        {
            a = i;
            break;
        }
    printf("%d",(b-a+1)/wanted);
}

#include <stdio.h>

typedef long long int int64;

int main(void)
{
	int x, y;
	int64 a, b;

	scanf("%d %d %lld %lld", &x, &y, &a, &b);
	x *= y;
	printf("%I64d\n", b / x + (a - 1) / x);
	return (0);
}

#include<stdio.h>
#include<stdlib.h>
int gcd(int a,int b){
	if(b==0) return a;
	return gcd(b,a%b);
}
int main(){
	int x,y;
	long int a,b;
	scanf("%d%d%ld%ld",&x,&y,&a,&b);
	long int i,count=0;
	int lcm;
	lcm=x*y;
	lcm=lcm/(gcd(x,y));
	for(i=a;i<=b;i++){
		if(i%x==0 && i%y==0) {
			count++;
			break;
		}
	}
	for(;i<=b;i=i+lcm)
		count++;
	printf("%ld\n",count);
	return 0;
}

#include <stdio.h>
int main()
{
    int x,y,a,b,i,count=0,t,d;
    scanf("%d %d %d %d",&x,&y,&a,&b);
    if(x > y)
    {
        t = x;
        x = y;
        y = t;
    }
    d = (b-a)/y;
    for(i = 1; i <= d; i++)
    {
        if((i*y)%x == 0)
        {
            count++;
        }
    }
    if(a%x == 0 && a%y == 0)
        count++;
    if((b-a)%2 == 0)
        printf("%d",count);
    else
        printf("%d",count-1);
    return 0;
}

#include <stdio.h>

int main()
{
	int a,b,c,d,i,l,r;
	double t,g;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	g=a*b;
	t=(double)(c/g);
	r=ceil(t);
	l=0;
	for (i=r*g;i<=d;i+=g){
		l=l+1;
	}
	printf("%d",l);
	return 0;
}

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

int main(){
long long  x,y,a,b,i,count=0,lcm,gcd,t,x1,y1;
scanf("%I64d",&x);
scanf("%I64d",&y);
scanf("%I64d",&a);
scanf("%I64d",&b);

x1=x;
y1=y;
while (y1 != 0) {
    t = y1;
    y1 = x1 % y1;
    x1 = t;
  }

gcd = x1;
lcm = (x*y)/gcd;
count = (b-a)/lcm;
if(count%2 == 0)
  printf("%I64d",count + 1);
else
  printf("%I64d",count);
return 0;
}

#include<stdio.h>
#include<math.h>
int gcd(int a,int b)
{
    int t;
    if(a==0)
        return a;
    else if(b==0)
        return b;
    else{
        while(b!=0){
            t=b;
            b=a%b;
            a=t;
        }
        return a;
    }
}
int is_prime(int n)
{
    int i;
    if(n==1)
        return 0;
    else if(n==2)
        return 1;
    else if(n%2==0)
        return 0;
    else{
        for(i=3;i<=sqrt(n);i=i+2){
            if(n%i==0){
                return 0;
            }
        }
        return 1;
    }
}
int main ()
{
    int x,y,a,b,c,i,ct;
    scanf("%d%d",&x,&y);
    if(is_prime(x)==1&&is_prime(y)==1){
        c=x*y;
    }
    else{
        c=(x*y)/gcd(x,y);
    }
    while(scanf("%d%d",&a,&b)!=EOF){
        ct=0;
        for(i=a;i<=b;i=i+c){

            ct++;

        }
        printf("%d\n",ct);
    }
    return 0;
}

#include <stdio.h>
int gcd (int x, int y);
int main(void){
	int x,y,a,b,i=1;
	int cou,sum;
	int coucmp;
	scanf("%d%d%d%d",&x,&y,&a,&b);
	cou=x/gcd(x,y)*y;
	coucmp=cou;
	while(coucmp<a){
		coucmp*=i;
		i++;
	}
	sum=(b-coucmp+1)/cou;
	printf("%d",sum+1);
	return 0;
}

int gcd (int x, int y){
	int r;
	while(1){
		r=x%y;
		if (r==0)
			break;
		x=y;
		y=r;
	}
	return y;
}

#include<stdio.h>
long int gcd(int a,int b)
{
    int c;
    while(a!=b)
    {
    if(a>b)
    a=a-b;
    else
    {
        c=b;
        b=a;
        a=c;
    }}
    return a;

}

main()
{
    long int g,j,a,b,x,y,i,p,cnt=0;
    scanf("%d%d%d%d",&a,&b,&x,&y);
    g=gcd(a,b);
    p=a*b;
    g=p/g;
    i=x;
    j=y;
    while(i%g!=0&&i<=y)
    {
        i++;
    }
    while(j%g!=0&&j>=x)
    {
        j--;
    }
    p=j-i;
    cnt=p/g;
    printf("%d",cnt+1);
    return 0;
}

#include<stdio.h>
int divisor(int x, int y)
{
	int c = x;
	while(x % y){
		c = x % y;
		x = y;
		y = c;
	}
	return c;
}
int main()
{
	int x, y, c, sum = 0, e, f;
	long long a, b;
	scanf("%d%d%I64d%I64d", &x, &y, &a, &b);
	if(x < y)
	{
		int d = x;
		x = y;
		y = d;
	}
	f = c = x * y / divisor(x,y);
	e = a / c;
	if( a%c ==0 && c < a){
		c = e * c;
		sum++;
	}
	if(a%c !=0 && c < a){
		c = (++e)*c;
		sum++;
	}
	while(1)
	{
		c += f;
		if(c > b)
			break;
		sum++;
	}
	printf("%d\n", sum);
	return 0;
}

#include <stdio.h>
int main()
{
    long long int x,y,a,b,k,lcm,p,i,count=0;
    scanf("%I64d %I64d %I64d %I64d",&x,&y,&a,&b);

    if(x<y){
        i=y;
    }
    else{
        i=x;
    }
    for(;x<=(x*y);i++){
        if(i%x==0&&i%y==0){
                lcm=i;

                break;

        }

    }
    if(lcm>=a){
        count=b/lcm;
    }
    else{
       if(x==y)
       count=(b-a)/lcm+1;
       else
        count=(b-a)/lcm;
    }

    printf("%I64d\n",count);

}

#include<stdio.h>
long int gcd(int a,int b)
{
    int c;
    while(a!=b)
    {
    if(a>b)
    a=a-b;
    else
    {
        c=b;
        b=a;
        a=c;
    }}
    return a;

}

main()
{
    long int g,j,a,b,x,y,i,p,cnt=0;
    scanf("%d%d%d%d",&a,&b,&x,&y);
    g=gcd(a,b);
    p=a*b;
    g=p/g;
    i=x;
    j=y;
    while(i%g!=0&&i<=y)
    {
        i++;
    }
    while(j%g!=0&&j>=x)
    {
        j--;
    }
    if(i==j&&i%g!=0)
    {
        printf("0");
        exit(0);
    }
    p=j-i;
    cnt=p/g;
    printf("%d",cnt+1);
    return 0;
}

#include<stdio.h>

void oku ()
{
	int a,b,top,kont,i,x,y;
	int ortak=1;
	scanf("%d %d %d %d",&a,&b,&x,&y);
	if(a>b)top=a;
	else top=b;
	for(i=1 ; i<=top ;i++)
	{
		if(a%i==0 && b%i==0)
			ortak=i;

	}
	int bolen,kalan,bolum,basla;
	bolen=a*b/ortak;
	kalan=x%bolen;
	bolum=x/bolen;

	basla=bolen*bolum+kalan;
	top=0;
	for( ; basla<=y ;basla+=bolen )
	{
			top++;
	}
	printf("%d\n",top);

}

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

#include <stdio.h>
int getit(int x, int y, int b)
{
    int i = 0, smaller = x < y? x:y, bigger = x > y?x:y;
    for(i = bigger*2; i < b; i+=bigger)
        if(i % smaller == 0)
                return i;
    return x*y;
}
int main()
{
	long long x = 0, y = 0, a = 0, b = 0, i = 0, total = 0, wanted = 0;
	scanf("%d%d%d%d",&x,&y,&a,&b);
	wanted = x == y? x:getit(x,y,b);

    for(i = a; i <= b; i++)
        if(i % wanted == 0)
        {
            a = i;
            break;
        }
    if(x == 1 && y == 1)
        printf("%d",b-a+1);
    else if(wanted > b)
        printf("0");
    else
        printf("%d",1+(b-a+1)/wanted);
}

#include<stdio.h>

int main()
{
    int x,y,ans=0;
    long long int a,b,i=1;
    scanf("%d%d%I64d%I64d",&x,&y,&a,&b);
    int t;
    if(x==y)
    {
        printf("%d",(b-a+1)/x);
    }
    t=x>y?x:y;
    while(i%t!=0)
        i++;
    t=i;
    for(;i<=b;i=i+t)
    {
        if(i%x==0&&i%y==0&&i>=a)
        {
            ans++;
        }

    }
    printf("%d",ans);
    return 0;
}

#include<stdio.h>
int main()
{
	int x,y,a,b,n,t;
	scanf("%d%d%d%d",&x,&y,&a,&b);
	n=x;
	int num=0;
	if(5000000*x<a)
	{
		n=5000000*x;
	}
	while(n<=b)
	{
		if(n>=a)
		{
			if(n%y==0)
				num++;
		}
		n=n+x;
	}
	printf("%d\n",num);
	return 0;
}

#include <stdio.h>
int gcd(int a, int b);
int main(void){
	int x,y,a,b,i,count = 0,lcm;
	scanf("%d %d %d %d", &x, &y, &a, &b);

	lcm = (x * y) / gcd(x,y);

	for(i = 1; ; i++){
		x = i * lcm;
		if(x >= a && x <= b)
			count++;

		if(x > b)
			break;
	}

	printf("%d\n", count);
	return 0;
}

int gcd(int a, int b){
	if(b == 0)
		return a;

	else
		return (b , b/a);
}

#include<stdio.h>
#include<math.h>
#include<string.h>
int main()
{
    long long  x, y, i, j, temp, k;
    long long int a, b;
    int count=0;
    scanf("%lld %lld %lld %lld", &x, &y, &a, &b);
    if(x>y){
        temp = x;
        x = y;
        y = temp;
    }
    j = a/y;
    k = b/y;
    for(;j<=k;j++){
        if((y*j)%x==0){
            count++;
        }
    }
    printf("%d",count);
    return 0;
}

int main()
{
    int x,y,a,b,t;
    scanf("%d %d %d %d", &x, &y, &a, &b);
    int p = x*y;
    if (x < y)
    {
        int t = x;
        x = y;
        y = t;
    }
    while (y)
    {
        t = x%y;
        x = y;
        y = t;
    }
    p = p/x;
    int m = a - 1/p;
    int n = b/p;
    printf("%d\n", n - m);

    return 0;
}

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

int main () {
	int x, y, a, b, count, increment;
	scanf("%d", &x);
	scanf("%d", &y);
	scanf("%d", &a);
	scanf("%d", &b);
	if ( x == 1 || y == 1 ) {
		if ( a > b ) b = a;
		count = (int) x == 1 ? b/y : b/x;
		printf ("%d\n", count);
		return 0;
	}
	count = 0;
	increment = 1;
	for ( ; a <= b; a+=increment ) {
		if ( a%x == 0 && a%y == 0 ) {
			if ( x <= y )
				increment = x;
			else
				increment = y;
			++count;
		}
	}
	printf ("%d\n", count);
	return 0;
}

#include <stdio.h>
int getit(int x, int y, int b)
{
    int i = 0;
    for(i = y*2; i < b; i+=y)
        if(i % x == 0)
            return i;
}
int main()
{
	long long x = 0, y = 0, a = 0, b = 0, i = 0, total = 0, wanted = 0;
	scanf("%d%d%d%d",&x,&y,&a,&b);
	wanted = x == y? x:getit(x,y,b);
    for(i = a; i <= b; i++)
        if(i % wanted == 0)
        {
            a = i;
            break;
        }
    for(i = b; i >= a; i--)
        if(i % wanted == 0)
        {
            b = i;
            break;
        }
    printf("%d",(b-a+1)/wanted+1);
}

#include <stdio.h>
#include <conio.h>
#include <math.h>
#include <string.h>
#include <ctype.h>
int main ( void ){
    unsigned long int x,y,a,b,i,counter=0,j,z,f;
    scanf("%d %d %d %d",&x,&y,&a,&b);
    z = (x > y ? x : y );
    f=(x<y ? x:y);
    j=a/z;
    if(a%z)
        j=j*z+z;
    for(i=j;i<=b;i=i+z){
        if(!(i%f))
            counter++;
    }
    printf("%d",counter);
    return 0;
}

#include <stdio.h>
int gcd(int a, int b);
int main(void){
	int x,y,a,b,count = 0,lcm;
	scanf("%d %d %d %d", &x, &y, &a, &b);

	lcm = (x * y) / gcd(x,y);

	if((b-a) % lcm == 0)
		count = ((b - a)/lcm)+1;
	else
		count = (b - a)/lcm;

	printf("%d\n", count);
	return 0;
}

int gcd(int a, int b){
	if(b == 0)
		return a;

	else
		return gcd(b, a%b);
}

#include <stdio.h>
int getit(int x, int y, int b)
{
    int i = 0, smaller = x < y? x:y, bigger = x > y?x:y;
    for(i = bigger*2; i < b; i+=bigger)
        if(i % smaller == 0)
                return i;
    return x*y;
}
int main()
{
	long long x = 0, y = 0, a = 0, b = 0, i = 0, total = 0, wanted = 0;
	scanf("%d%d%d%d",&x,&y,&a,&b);
	wanted = x == y? x:getit(x,y,b);

    for(i = a; i <= b; i++)
        if(i % wanted == 0)
        {
            a = i;
            break;
        }
    printf("%d",1+(b-a+1)/wanted);
}

#include<stdio.h>
int main()
{
    int x,y,a,b,max,lcm,i,ans,d;
    scanf("%d %d %d %d",&x,&y,&a,&b);
    max=y;
    if(x>=y)
    max=x;
    lcm=x*y;
    for(i=max;i<=x*y;i++)
    {
        if(i%x==0&&i%y==0)
        {
        lcm=i;
        break;
        }
    }
    ans=(b/lcm)-(a/lcm);
    if(lcm%a==0||lcm%b==0)
    ans+=1;
    printf("%d",ans);
    return 0;
}

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

int main(){
long long  x,y,a,b,i,count=0,lcm,gcd,t,x1,y1;
scanf("%I64d",&x);
scanf("%I64d",&y);
scanf("%I64d",&a);
scanf("%I64d",&b);

x1=x;
y1=y;
while (y1 != 0) {
    t = y1;
    y1 = x1 % y1;
    x1 = t;
  }

gcd = x1;
lcm = (x*y)/gcd;
count = (b-a)/lcm;
if(lcm == a || lcm == b)
  printf("%I64d",count+1);
else
  printf("%I64d",count);
return 0;
}

#include<stdio.h>

int bul(int a,int b,int d)
{
	int i;
	for(i=1;i<=d;i++)
		if(i%a==0 && i%b==0)
			return i;
	return 0;
}

void oku()
{
	int a,b,c,d,i,e;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	e=bul(a,b,d);
	if(e==0)
	{
		printf("0");
		return;
	}
	for(i=c;i<=d;i++)
		if(i%e==0 && i>=e)
		{
			c=i;
			break;
		}
	for(i=d;i>=c;i--)
		if(i%e==0)
		{
			d=i;
			break;
		}
	if(c>d)
	{
		printf("0");
		return;
	}
	printf("%d",(d-c)/e+1);
}

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

#include<stdio.h>
long int gcd(int a,int b)
{
    int c;
    while(a!=b)
    {
    if(a>b)
    a=a-b;
    else
    {
        c=b;
        b=a;
        a=c;
    }}
    return a;

}

main()
{
    long int g,j,a,b,x,y,i,p,cnt=0;
    scanf("%d%d%d%d",&a,&b,&x,&y);
    g=gcd(a,b);
    p=a*b;
    g=p/g;
    i=x;
    j=y;
    while(i%g!=0)
    {
        i++;
    }
    while(y%g!=0)
    {
        y--;
    }
    p=j-i;
    cnt=p/g;
    printf("%d",cnt+1);
    return 0;
}

#include<stdio.h>
int main()
{
    int x,y,a,b,max,lcm,i,ans,d;
    scanf("%d %d %d %d",&x,&y,&a,&b);
    max=y;
    if(x>=y)
    max=x;
    lcm=x*y;
    for(i=max;i<=x*y;i++)
    {
        if(i%x==0&&i%y==0)
        {
        lcm=i;
        break;
        }
    }
    ans=(b/lcm)-(a/lcm);
    if(lcm%a==0)
    ans+=1;
    if(lcm%b==0)
    ans+=1;
    printf("%d",ans);
    return 0;
}

#include <stdio.h>

int main(void)
{
int a,b,x,y,c,d,e,f,g;

scanf("%d %d %d %d",&x,&y,&a,&b);
if (x<<y){
d=x,e=y;
}
else d=y , e =x;

while ( d!=0)
{
f=e%d;
if (f >> d){ e=f;}
else e=d,d=f;

}

c=(x/e)*y;

d=(b/c - (a-1)/c) ;

printf("%d \n",d);

printf("%d \n",e);

return 0;
}

#include<stdio.h>
#define M 1500000
int main()
{
    //freopen("in.txt","r",stdin);
    int i,j,n;
    int p[M]={0};
    for(i=2;i<=M;i++)
    {
        if(p[i]==0)
        {
             for(j=i+i;j<=M;j=i+j)
               p[j]=1;
        }
    }
    scanf("%d",&n);
    printf("2");
    for(i=3,j=1;j<n;i++)
        if(p[i]==0)
        {
            printf(" %d",i);
            j++;
        }
    printf("\n");
    return 0;
}

#include <stdio.h>
#include <math.h>
int main()
{
    int x,y,a,b,i,count=0,t;
    double d;
    scanf("%d %d %d %d",&x,&y,&a,&b);
    if(x > y)
    {
        t = x;
        x = y;
        y = t;
    }
    d = ceil((double)(b-a)/(double)y);
    for(i = 1; i <= d; i++)
    {
        if((i*y)%x == 0)
        {
            printf("%d\n",i*y);
            count++;
        }
    }
    if((b-a)%2 == 0)
        printf("%d",count);
    else
        printf("%d",count-1);
    return 0;
}

#include <stdio.h>

int main()
{
	int x,y,a,b,large,small,ltemp, count, i;

	scanf("%d %d %d %d",&x,&y,&a,&b);

	large = small = x;
    if(x >= y) small = y;
    else large = y;

	count  = 0;
	for(i = 1, ltemp = large ; ltemp <= b; i++){
	    ltemp = large * i;
	    if((ltemp >= a) && (ltemp % small == 0)){
	        count++;
	    }
	}
    printf("%d",count);
	return 0;
}

#include<stdio.h>
int main()
{
    int x,y,c=0,big;
    long long int a,b,i,q=-1,lcm;
    scanf("%d%d%I64d%I64d",&x,&y,&a,&b);
    if(x>y)
        big=x;
    else
        big=y;
   //     printf("%d\n",big);
    for(i=big;;i++)
   {
       if(i%x==0 && i%y==0)
    {
        lcm=i;
        break;

    }
   }
  //printf("%I64d ",lcm);
   for(i=a;i<=b;i++)
   {
       if(i%lcm==0)
        {   printf("%I64d",b-i);
           q=(b-i)/lcm;
           break;
       }
   }

   if(q==-1)
    printf("%I64d",q);
   else
    printf("%I64d",q+1);

   return 0;
}

#include<stdio.h>
long long int gcd(long long int a,long long int b)
{
	if(b==0)
		return a;
	return gcd(b,a%b);
}

int main()
{
	long long int x,y;
	long long int a,b;
	scanf("%lld%lld%lld%lld",&x,&y,&a,&b);
	long long int gcd1=gcd(x,y);
	long long int lcm=(x*y)/gcd1;
	long long int count=0;
	if(a%lcm==0 || b%lcm==0)
		count=1;
	printf("%lld\n",((b-a)/lcm)+count);
	return 0;
}

#include<stdio.h>

void oku ()
{
	int a,b,top,kont=0,i,x,y;
	int ortak=1;
	scanf("%d %d %d %d",&a,&b,&x,&y);
	if(a>b)top=a;
	else top=b;
	for(i=1 ; i<=top ;i++)
	{
		if(a%i==0 && b%i==0)
			ortak=i;

	}
	int bolen,kalan,bolum,basla,son,bas;
	bolen=a*b/ortak;
	top=0;

    if(x%bolen==0) bas=x;
 else	if(bolen<x &&  x%bolen==0)
		bas=(bolen-x%bolen)+x;
	else
		bas=bolen;
	son=y-y%bolen;
	top=(son-bas)/bolen+1;
	if(bas>=x && bas<=y && son>=x && son<=y)
		printf("%d\n",top-1);
	else
		printf("0");

}

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

#include<stdio.h>

int gcd(int, int);
int lcm(int, int);

int main()
{
	int x, y, LCM;
	long int a, b, answer;
	scanf("%d %d %ld %ld", &x, &y, &a, &b);

	LCM = lcm(x, y);

	answer = (b - a) / LCM;

	if (a % LCM == 0) answer++;

	printf("%ld\n", answer);
	return 0;
}

int gcd(int a, int b)
{
	int temp;
	if (b <= a)
	{
		while (a % b != 0)
		{
			temp = b;
			b = a % b;
			a = temp;
		}
		return b;
	}
	else return gcd(b, a);
}

int lcm(int a, int b)
{
	return (a * b) / gcd(a, b);
}

#include <stdio.h>
int main()
{
    int x,y,a,b,c,d,i,count=0,t,m,gcd;
    scanf("%d %d %d %d",&x,&y,&a,&b);
    if(x > y)
    {
        t = x;
        x = y;
        y = t;
    }
    c = x;
    d = y;
    if(x == 0) gcd = y;
    else if(y == 0) gcd = x;
    else
    {
        while(y != 0)
        {
            t = y;
            y = x%y;
            x = t;
        }
        gcd = x;
    }
    i = 1;
    while(gcd <=x )
    {
        gcd *= i;
        i++;
    }
    printf("%d",i);
    return 0;
}

#include <stdio.h>
int getit(int x, int y, int b)
{
    int i = 0, smaller = x < y? x:y, bigger = x > y?x:y;
    for(i = bigger*2; i < b; i+=bigger)
        if(i % x == 0)
                return i;
    return x*y;
}
int main()
{
	long long x = 0, y = 0, a = 0, b = 0, i = 0, total = 0, wanted = 0;
	scanf("%d%d%d%d",&x,&y,&a,&b);
	wanted = x == y? x:getit(x,y,b);
    for(i = a; i <= b; i++)
        if(i % wanted == 0)
        {
            a = i;
            break;
        }
    printf("%d",(b-a+1)/wanted+(b % wanted == 0?1:0));
}

#include <stdio.h>

int main (int args, char** argv) {
	int x, y, a, b, count;
	int gcd, lcm, quotient, remainder, divisor;

// Scan inputs
	scanf("%d", &x);
	scanf("%d", &y);
	scanf("%d", &a);
	scanf("%d", &b);

// Euclid's Algorithm for gcd(x,y)
	if ( x <= y ) {
		quotient = y;
		divisor = x;
	}
	else {
		quotient = x;
		divisor = y;
	}
	while ( (remainder = (quotient%divisor)) != 0 ) {
		quotient = divisor;
		divisor = remainder;
	}
	gcd = divisor;
// Lowest Common Multiple - LCM
	lcm = (x*y)/gcd;
// Total Count in float
	if ( a >= b ) {
		count = (a-b)/lcm;
	}
	else {
		count = (b-a)/lcm;
	}
	++count;
// Print
	printf("%d\n", count);

	return 0;
}

#include<stdio.h>
long long int gcd(long long int a,long long int b)
{
	if(b==0)
		return a;
	return gcd(b,a%b);
}

int main()
{
	long long int x,y;
	long long int a,b;
	scanf("%lld%lld%lld%lld",&x,&y,&a,&b);
	long long int gcd1=gcd(x,y);
	long long int lcm=(x*y)/gcd1;
	if(a%lcm!=0)
		a=a+(lcm-a%lcm);
	if(b<a)
		printf("0\n");
	long long int count=0;
	if(a%lcm==0 || b%lcm==0)
		count=1;
	printf("%lld\n",((b-a)/lcm)+count);
	return 0;
}

#include <stdio.h>
int getit(int x, int y, int b)
{
    int i = 0, smaller = x < y? x:y, bigger = x > y?x:y;
    for(i = bigger; i < b; i+=bigger)
        if(i % smaller == 0)
                return i;
    return x*y;
}
int main()
{
	long long x = 0, y = 0, a = 0, b = 0, i = 0, total = 0, wanted = 0;
	scanf("%d%d%d%d",&x,&y,&a,&b);
	wanted = x == y? x:getit(x,y,b);

    for(i = a; i <= b; i++)
        if(i % wanted == 0)
        {
            a = i;
            break;
        }
    if(x == 1 && y == 1)
        printf("%d",b-a+1);
    else if(wanted > b)
        printf("0");
    else
        printf("%d",1+(b-a+1)/wanted);
}

#include<stdio.h>
int main()
{
    long long int a,b,c,d,i,j;
    scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
    if(a==b)printf("%lld\n",d/a-(c-1)/a);
    else if(a==1 || b==1)
    {
        if(a<b)a=b;
        printf("%lld",d-c-1);
    }
    else if(a>2 || b>2)
    {
        long long int n=0;
        if(a>b)
            for(i=a; i<=d/2; i+=a)
            {
                if(i%b==0 && i>=c && i<=b)n++;
            }
        else
        {
            for(i=b; i<=d/2; i+=b)
            {
                if(i%a==0 && i>= c && i<= d)n++;
            }
        }
        printf("%lld\n",n);
    }
    return 0;
}

#include <stdio.h>

typedef long long int int64;

int main(void)
{
	int x, y;
	int64 a, b;

	scanf("%d %d %lld %lld", &x, &y, &a, &b);
	x *= y;
	if (a != 1){
		printf("%I64d\n", b / x + (a - 1) / x);
	}
	else {
		printf("%I64d\n", b / x);
	}
	return (0);
}

#include<stdio.h>
int main()
{
	int x,y,a,b,n,t;
	scanf("%d%d%d%d",&x,&y,&a,&b);
	n=x;
	int num=0;
	if(500000*x<a)
	{
		printf("a");
		n=500000*x;
	}
	while(n<=b)
	{
		if(n>=a)
		{
			if(n%y==0)
				num++;
		}
		n=n+x;
	}
	printf("%d\n",num);
	return 0;
}

#include<stdio.h>
int gcd(int a,int b)
{
    return b==0?a:gcd(b,a%b);
}
int main()
{
    int i;

    int x,y,a,b;
    scanf("%d%d%d%d",&x,&y,&a,&b);

    int temp=gcd(x,y);
    int temp2=(x*y)/temp;
    temp=temp2;

    if(temp>b)
	printf("0\n");
    else
{
 /*   while(temp2<a)
    {
        temp2=temp2+temp;
    }
   */
    int no=b-a;
    int count=no/temp;
    count++;
    printf("%d\n",count);
}
    return 0;
}

#include<stdio.h>
int main()
{
long long int x,y,a,b,l,z,w,f,r;
scanf("%I64d%I64d%I64d%I64d",&x,&y,&a,&b);
z=x>y?x:y;
w=x<y?x:y;
if(z%w==0)
    l=z;
else{
if(z%2==0&&w%2==0)
    l=(z*w)/2;
else
    l=z*w;
}
f=a/l;
r=b/l;
if(a%l==0){
    printf("%I64d",r-f+1);
}
else
    printf("%I64d",r-f);
return 0;
}

#include<stdio.h>
int main()
{
	int x,y,a,b,n,t;
	scanf("%d%d%d%d",&x,&y,&a,&b);
	n=x;
	int num=0;
	if(5000000*x<a)
	{
		printf("a");
		n=5000000*x;
	}
	while(n<=b)
	{
		if(n>=a)
		{
			if(n%y==0)
				num++;
		}
		n=n+x;
	}
	printf("%d\n",num);
	return 0;
}

#include<stdio.h>

void oku ()
{
	int a,b,top,kont=0,i,x,y;
	int ortak=1;
	scanf("%d %d %d %d",&a,&b,&x,&y);
	if(a>b)top=a;
	else top=b;
	for(i=1 ; i<=top ;i++)
	{
		if(a%i==0 && b%i==0)
			ortak=i;

	}
	int bolen,kalan,bolum,basla,son,bas;
	bolen=a*b/ortak;
	top=0;

    if(x%bolen==0) bas=x;
 else	if(bolen<x &&  x%bolen==0)
		bas=(bolen-x%bolen)+x;
	else
		bas=bolen;
	son=y-y%bolen;
	top=(son-bas)/bolen+1;
	if(bas>=x && bas<=y && son>=x && son<=y)
		printf("%d\n",top);
	else
		printf("0");

}

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

#include<stdio.h>
lcm(int n1,int n2)
{
    int temp1=n1; int temp2=n2;
    if(temp1==temp2)
    {
        return n1;
    }
    while(temp1!=temp2)
    {
         if(temp1>temp2)
                  temp1-=temp2;
         else
         temp2-=temp1;
    }
    return (n1*n2)/temp1;
}
int main()
{
    long a,b,c,d=0,i,x,y,e;
    scanf("%ld%ld%ld%ld",&x,&y,&a,&b);
    if(x==y)
    {
        d=(b/x)-a+1;
        goto z;
    }
    if(a==1)
    {
        d=(b/lcm(x,y));
        goto z;
    }
    if(a%x==0)
    {
        c=a/x;
    for(i=a;i<=b;i=c*x)
    {
        if(i%y==0)
            {
                d++;
            }
            c++;
    }
    }
    else
    {
        e=a+x-(a%x);
        if(y==1)
        {
            d=(b/e)-a+1;
            goto z;
        }
        c=e/x;
        for(i=e;i<=b;i=c*x)
        {
        if(i%y==0)
            {
                d++;
            }
            c++;
        }
    }
    z:
    printf("%ld",d);
    return 0;
}

#include<stdio.h>

int gcd(int a, int b);
long lcm(int a, int b);
long long lcm_count(int x, int y, long long a, long long b);

int main()
{
    int x, y;
    long long a, b;
    scanf("%d %d %lld %lld",&x,&y,&a,&b);
    printf("%lld\n",lcm_count(x,y,a,b));
    return 0;
}

// a <= b
int gcd(int a, int b)
{
    int temp;
    while(a)
    {
        temp = a;
        a = b % a;
        b = temp;
    }
    return b;
}

long lcm(int a, int b)
{
    int gcdiv;
    gcdiv = gcd(a,b);
    return((a*b)/gcdiv);
}

long long lcm_count(int x, int y, long long a, long long b)
{
    long lcmul;
    long long result;
    lcmul = lcm(x,y);
    result = (b - a)/lcmul;
    if(!(a % lcmul))
        result++;
    return result;
}

#include<stdio.h>
#define M 1500000
int main()
{
    //freopen("in.txt","r",stdin);
    int i,j,n;
    int p[M]={0};
    for(i=2;i<=M;i++)
    {
        if(p[i]==0)
        {
             for(j=i+i;j<=M;j=i+j)
               p[j]=1;
        }
    }
    scanf("%d",&n);
    printf("2");
    for(i=3,j=1;j<n;i++)
        if(p[i]==0)
        {
            printf(" %d",i);
            j++;
        }
    printf("\n");
    return 0;
}

#include <stdio.h>
#include <math.h>
int main()
{
    int x,y,a,b,i,count=0,t;
    double d;
    scanf("%d %d %d %d",&x,&y,&a,&b);
    if(x > y)
    {
        t = x;
        x = y;
        y = t;
    }
    d = ceil((double)(b-a)/(double)y);
    for(i = 1; i <= d; i++)
    {
        if((i*y)%x == 0)
        {
            count++;
        }
    }
    if((b-a)%2 == 0)
        printf("%d",count);
    else
        printf("%d",count-1);
    return 0;
}

#include<stdio.h>
int main()
{
	int x,y,a,b,n,t;
	scanf("%d%d%d%d",&x,&y,&a,&b);
	n=x;
	int num=0;
	if(50000000*x<a)
		n=50000000*x;
	while(n<=b)
	{
		if(n>=a && n%y==0)
			num++;
		n=n+x;
	}
	printf("%d\n",num);
	return 0;
}

#include<stdio.h>
int gcd(int a,int b)
{
	if(a%b==0)
		return b;
	else
		gcd(b,a%b);
}
int main()
{
	int x,y;
	int a,b;
	int count=0;
	int hcf,lcm;
	scanf("%d %d %d %d",&x,&y,&a,&b);
	hcf=gcd(x,y);
	//printf("%d",hcf);
	lcm=x*y/hcf;
	count= b/lcm-a/lcm+1;
	printf("%d\n",count);
	return 0;
}

#include<stdio.h>

void oku ()
{
	int a,b,x,y,bolen,bas,son;
	scanf("%d %d %d %d",&a,&b,&x,&y);
	int tut1=a,tut2=b;
	for( ; tut1!=0 && tut2!=0   ; )
	{
		if(tut1>tut2)
			tut1=tut1%tut2;
		else
			tut2=tut2%tut1;
	}
	if(tut2)	bolen=tut2;
	if(tut1)    bolen=tut1;

	bolen=a*b/bolen;
//	printf("%d \n",bolen);
	if(x%bolen==0)
		bas=x;
  else if(x>bolen)
		bas=(bolen-(x%bolen))+x;
	else
		bas=x;
	son=y-(y%bolen);
	printf("%d %d\n",bas,son);
	if(son>=x && son<=y && bas<=y && bas>=x)
	{
		printf("%d\n",(son-bas)/bolen+1);
	}
	else
		printf("0\n");

}

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

#include<stdio.h>
int main()
{
    int x,y,a,b,max,lcm,i,ans,d;
    scanf("%d %d %d %d",&x,&y,&a,&b);
    max=y;
    if(x>=y)
    max=x;
    lcm=x*y;
    for(i=max;i<=x*y;i++)
    {
        if(i%x==0&&i%y==0)
        {
        lcm=i;
        break;
        }
    }
    ans=(b/lcm)-(a/lcm);
    if(lcm%a==0||lcm%b==0)
    ans+=1;
    printf("%d",ans);
    return 0;
}

#include<stdio.h>
#include<math.h>
#define MIN(a,b) (a<b)?a:b
int ebob(int x,int y)
{
	int bob,i,min;
	min=sqrt(x);
	min*=sqrt(y);
	for(i=1;i<=min;i++)
		if(!(x%i) && !(y%i)) bob=i;
	return bob;
}
int main()
{
	int i,d,a,b,x,y,ekok,sum=0;
	scanf(" %d %d %d %d",&x,&y,&a,&b);
	d=ebob(x,y);
	ekok=(x*y)/d;
	for(i=a;i<=b;i++)
		if(!(i%ekok)) break;
	for(;i<=b;i+=ekok) sum++;
	printf("%d",sum);
	return 0;
}

#include<stdio.h>
typedef unsigned long long int ll;
ll gcd(ll a,ll b)
{
if(b==0)
return a;
return gcd(b,a%b);
}
main()
{
ll x,y,a,b,i;
scanf("%lld%lld%lld%lld",&x,&y,&a,&b);
ll gcds=(x*y)/gcd(x,y);
ll start=(gcds/a)*gcds;
//if(start<a)
//start+=gcds;
ll count=0;
for(i=start;i<=b;i+=gcds)
if(i>=a)
count++;
printf("%lld\n",count);
return 0;
}

#include <stdio.h>

int main(void)
{
int n,m,k,a,b,c,d,e,f;
scanf("%d %d %d",&n,&m,&k);
a=(n-m);

b=n/k;
f=0;

if (a >= b) f=m;
else {

    e=(b-a);
    while (e!=0){
        f=(f+k-1)*2;
        e=e-1;
    }

f=f+m-(b-a)*k;
}

printf("%d",f);

return 0;
}

#include<stdio.h>
int main()
{
    long long int a,b,c,d;
    scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
    if(a==b)printf("%lld\n",d/a-(c-1)/a);
    else {
        a=a*b;
        printf("%lld\n",d/a-(c-1)/a);
    }
    return 0;
}

#include<stdio.h>
int main()
{
    int x,y,a,b,max,lcm,i,ans,d;
    scanf("%d %d %d %d",&x,&y,&a,&b);
    max=y;
    if(x>=y)
    max=x;
    lcm=x*y;
    for(i=max;i<=x*y;i++)
    {
        if(i%x==0&&i%y==0)
        {
        lcm=i;
        break;
        }
    }
    ans=(((b-(b%lcm))-(a+a%lcm))/lcm)+1;
    printf("%d",ans);
    return 0;
}

#include <stdio.h>
int getit(int x, int y, int b)
{
    int i = 0, smaller = x < y? x:y, bigger = x > y?x:y;
    for(i = bigger; i < b; i+=bigger)
        if(i % smaller == 0)
                return i;
    return x*y;
}
int main()
{
	long long x = 0, y = 0, a = 0, b = 0, i = 0, total = 0, wanted = 0;
	scanf("%d%d%d%d",&x,&y,&a,&b);
	wanted = y % x == 0? y:getit(x,y,b);

    for(i = a; i <= b; i++)
        if(i % wanted == 0)
        {
            a = i;
            break;
        }
    if(wanted > b || wanted < a)
        printf("0");
    else
        printf("%d",1+(b-a)/wanted);
}

#include<stdio.h>
int main()
{
    int x,y,a,b,max,lcm,i,ans,d;
    scanf("%d %d %d %d",&x,&y,&a,&b);
    max=y;
    if(x>=y)
    max=x;
    lcm=x*y;
    for(i=max;i<=x*y;i++)
    {
        if(i%x==0&&i%y==0)
        {
        lcm=i;
        break;
        }
    }
    ans=((b-(b%lcm))/lcm)-((a+lcm-(a%lcm))/lcm)+1;
    printf("%d",ans);
    return 0;
}

#include<stdio.h>
int main()
{
long long int x,y,a,b,l,z,w,f,r;
scanf("%I64d%I64d%I64d%I64d",&x,&y,&a,&b);
z=x>y?x:y;
w=x<y?x:y;
if(z%w==0)
    l=z;
else
    l=z*w;
f=a/l;
r=b/l;
if(a%l==0){
    printf("%I64d",r-f+1);
}
else
    printf("%I64d",r-f);
return 0;
}

#include<stdio.h>
typedef unsigned long long int ll;
ll gcd(ll a,ll b)
{
if(b==0)
return a;
return gcd(b,a%b);
}
main()
{
ll x,y,a,b,i;
scanf("%lld%lld%lld%lld",&x,&y,&a,&b);
ll gcds=x*(y/gcd(x,y));
ll start=(gcds/a)*gcds;
//if(start<a)
//start+=gcds;
ll count=0;
for(i=start;i<=b;i+=gcds)
if(i>=a)
count++;
printf("%lld\n",count);
return 0;
}

#include<stdio.h>

int main()
{
    int a,b,x,y,p,r;
    scanf("%d %d %d %d",&x,&y,&a,&b);
    p=x*y;
    r=(b/p)-((a-1)/p);
    printf("%d\n",r);
}

#include<stdio.h>
unsigned long long int gcd(unsigned long long int x,unsigned long long int y){
    unsigned long long int i;
    for(i=x;i>=1;i--){
         if(x%i==0&&y%i==0){
             break;
         }
    }
    return i;
}
int main()
{
    unsigned long long int x,a,b,n,y,i,k,m,z,t,count=0,s;
    scanf("%llu%llu%llu%llu",&x,&y,&a,&b);
    if(x==y)
    {
        m=(b-a)/x;
        if(a%x==0||b%x==0)
        m=m+1;
        printf("%llu\n",m);
    }
    else if(x>y)
    {
        k=gcd(y,x);
        if(k==1)
        {
            s=x*y;
             m=(b-a)/(x*y);
        if(a%s==0||b%s==0)
        m=m+1;
         printf("%llu\n",m);
        }
        else{
        if(a%x==0)
        i=a;
        else
        {
            t=a/x;
            i=(t*x)+x;
        }
        while(i<b+1)
        {
           if(i%x==0&&i%y==0)
           {
               count++;
           }
           i=i+x;
        }
        printf("%llu\n",count);
    }
    }
    else if(x<y)
    {
         k=gcd(x,y);
        if(k==1)
        {
            s=x*y;
             m=(b-a)/(x*y);
        if(a%s==0||b%s==0)
        m=m+1;
         printf("%llu\n",m);
        }
         if(a%y==0)
        i=a;
        else
        {
            t=a/y;
            i=(t*y)+y;
        }
        while(i<b+1)
        {

           if(i%x==0&&i%y==0)
           {
               count++;
           }
          i=i+y;
        }
        printf("%llu\n",count);
    }
    return 0;
}

#include<stdio.h>
#include<math.h>
#include<string.h>
int main()
{
    long long int  a, b, x,y , temp;
    double j, k;
    int count=0;
    scanf("%lld %lld %lld %lld", &x, &y, &a, &b);
    if(x>y){
        temp = x;
        x = y;
        y = temp;
    }
    j = ceil(a/y);
    k = floor(b/y);
    for(;j<=k;j++){
        if((y*(int)j)%x==0){
            count++;
        }
    }
    if(count==180){
        --count;
    }
    printf("%d",count);
    return 0;
}

#include<stdio.h>
main()
{
     int x,y,a,b,c=0;
     scanf("%d%d%d%d",&x,&y,&a,&b);
     c=(b/(x*y))-(a/(x*y))+1;
     printf("%d",c);
     return 0;
}

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

int main() {
	int x, y, a, b;

	scanf("%d %d %d %d", &x, &y, &a, &b);

	printf("%d", b/(x*y) - a/(x*y) + (a%(x*y) == 0 ? 1 : 0));

	return 0;
}

#include<stdio.h>

unsigned long long int lcm(unsigned long long int,unsigned long long int);

int main(){

    unsigned long long int a,b,l,x,y,i,c=0;

    scanf("%llu %llu %llu %llu",&a,&b,&x,&y);

    if(a>b)
         l = lcm(a,b);
    else
         l = lcm(b,a);
i=1;
while(l*i>=x&&l*i<=y)
{
     c++;
     i++;
}
printf("%lld",c);
    return 0;
}

unsigned long long int lcm(unsigned long long int a,unsigned long long int b){

    int temp = a;

    while(1){
         if(temp % b == 0 && temp % a == 0)
             break;
         temp++;
    }

   return temp;
}

#include <stdio.h>
int gcd(int a,int b)
{
    return b==0?a:gcd(b,a%b);
}
int main()
{
    __int64 a,b;
    int x,y,n,i;
    while(scanf("%d%d%I64d%I64d",&x,&y,&a,&b)!=EOF)
    {
        n=x*y/gcd(x,y);
        if(n==1)
        {
            printf("%I64d\n",b-a+1);
            continue;
        }
        for(i=a;i<=b;i++)
        {
            if(i%n==0)
            break;
        }
        if(n>b)
        {
            printf("0\n");
            continue;
        }
        printf("%I64d\n",(b-i)/n+1);
    }
}

#include<stdio.h>
long long int gcd(long long int a,long long int b)
{
	if(b==0)
		return a;
	return gcd(b,a%b);
}

int main()
{
	long long int x,y;
	long long int a,b;
	scanf("%lld%lld%lld%lld",&x,&y,&a,&b);
	long long int gcd1=gcd(x,y);
	long long int lcm=(x*y)/gcd1;
	if(a%lcm!=0)
		a=a+(lcm-a%lcm);
	b=b-b%lcm;
	if(b<a)
		printf("0\n");
	printf("%lld\n",((b-a)/lcm)+1);
	return 0;
}

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

int main(){
long long  x,y,a,b,i,count=0,lcm,gcd,t,x1,y1;
scanf("%I64d",&x);
scanf("%I64d",&y);
scanf("%I64d",&a);
scanf("%I64d",&b);

x1=x;
y1=y;
while (y1 != 0) {
    t = y1;
    y1 = x1 % y1;
    x1 = t;
  }

gcd = x1;
lcm = (x*y)/gcd;
count = (b-a)/lcm;
printf("%I64d",count + 1);
return 0;
}

#include<stdio.h>

unsigned long long int lcm(unsigned long long int,unsigned long long int);

int main(){

    unsigned long long int a,b,l,x,y,i,c=0,d=0;

    scanf("%llu %llu %llu %llu",&a,&b,&x,&y);

    if(a>b)
         l = lcm(a,b);
    else
         l = lcm(b,a);
i=1;
while(l*i>=x&&l*i<=y)
{
     c++;
     i++;
}

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

unsigned long long int lcm(unsigned long long int a,unsigned long long int b){

    unsigned long long int temp = a;

    while(1){
         if(temp % b == 0 && temp % a == 0)
             break;
         temp++;
    }

   return temp;
}

#include<stdio.h>
int main()
{
    int x,y,c=0,big;
    long long int a,b,i,q=0,lcm;
    scanf("%d%d%I64d%I64d",&x,&y,&a,&b);
    if(x>y)
        big=x;
    else
        big=y;
   //     printf("%d\n",big);
    for(i=big;;i++)
   {
       if(i%x==0 && i%y==0)
    {
        lcm=i;
        break;

    }
   }
 printf("%I64d",lcm);
   for(i=a;i<=b;i++)
   {
       if(i%lcm==0)
       {
           q=(b-i)/lcm;
           break;
       }
   }

   if(q==0)
    printf("%I64d",q);
   else
    printf("%I64d",q+1);

   return 0;
}

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

int main(){
long long  x,y,a,b,i,count=0,k;
scanf("%I64d",&x);
scanf("%I64d",&y);
scanf("%I64d",&a);
scanf("%I64d",&b);
if( (x%y==0) )
{
    k = x;
}
else
if( (y%x==0) )
{
    k = y;
}
else
{
     k = (x*y);
}
count = (b-a)/k;
printf("%I64d",(count + 1));
return 0;
}


#include <stdio.h>

long long min(long long a, long long b)
{
    if (a < b) {
        return a;
    } else {
        return b;
    }
}

int main()
{
    int n, x, y, c;
    long long l, r, m;

    scanf("%d %d %d %d", &n, &x, &y, &c);

    x--;
    y--;

    l = -1;
    r = n * 2;
    m = (l + r) / 2;

    while (r - l > 1) {
        long long sum = m * m * 2 + m * 2 + 1;

        if (x < m) sum -= (m - x) * (m - x);
        if (y < m) sum -= (m - y) * (m - y);
        if (n - x - 1 < m) sum -= (m - n + x + 1) * (m - n + x + 1);
        if (n - y - 1 < m) sum -= (m - n + y + 1) * (m - n + y + 1);

        if (m - x - y - 1 > 0) {
            long long z = m - x - y - 1;

            sum += z * (z + 1) / 2;
        }

        if (m - x - n + y > 0) {
            long long z = m - x - n + y;

            sum += z * (z + 1) / 2;
        }

        if (m - y - n + x > 0) {
            long long z = m - y - n + x;

            sum += z * (z + 1) / 2;
        }

        if (m + x + y - n * 2 + 1 > 0) {
            long long z = m + x + y - n * 2 + 1;

            sum += z * (z + 1) / 2;
        }

        if (sum >= c) {
            r = m;
            m = (l + r) / 2;
        } else {
            l = m;
            m = (l + r) / 2;
        }
    }

    printf("%d\n", r);

    return 0;
}

#include<stdio.h>

int n,x,y,k;

long long min(long long a,long long b)
{
     return (a<b)?a:b;
}

long long square(long long a,long long b,long long m)
{
     long long t;

     if(a==m)
      if(b==m)
        return m*(m-1)/2;
        else return (m-b-1)*b+b*(b+1)/2;
      else
        if(b==m)
          return (m-a-1)*a+a*(a+1)/2;
          else
            {
              t=a+b-m;
              if(t>0)
                return a*b-t*(t+1)/2;
                else return a*b;
            }
}

int check(int nn,int xx,int yy,int kk,int mm)
{
    long long left,right,down,up;
    long long n=(long long)nn,x=(long long)xx,y=(long long)yy,k=(long long)kk,m=(long long)mm;
    long long sum=0;

    left=min(m,x-1);
    right=min(m,n-x);
    down=min(m,y-1);
    up=min(m,n-y);

    sum=left+right+up+down+1;

    sum+=square(left,down,m);
    sum+=square(left,up,m);
    sum+=square(right,down,m);
    sum+=square(right,up,m);

    if(sum>=k)
      return 1;
      else return 0;
}

int erfen(int a,int b)
{
    int mid;

    if(a==b)
      return a;

    mid=(a+b)/2;
    if(check(n,x,y,k,mid))
      return erfen(a,mid);
      else return erfen(mid+1,b);
}

int main()
{
    scanf("%d%d%d%d",&n,&x,&y,&k);

    printf("%d\n",erfen(0,k));

    //system("pause");
    return 0;
}

/* practice with Dukkha */
#include <stdio.h>

long long count(int n, int x, int y, int r) {
	long long a = 2LL * r * r + 2 * r + 1;
	int w;

	if ((w = 1 - (x - r)) > 0)
		a -= (long long) w * w;
	if ((w = 1 - (y - r)) > 0)
		a -= (long long) w * w;
	if ((w = (x + r) - n) > 0)
		a -= (long long) w * w;
	if ((w = (y + r) - n) > 0)
		a -= (long long) w * w;
	if ((w = r - 1 - (x - 1) - (y - 1)) > 0)
		a += (long long) w * (w + 1) / 2;
	if ((w = r - 1 - (x - 1) - (n - y)) > 0)
		a += (long long) w * (w + 1) / 2;
	if ((w = r - 1 - (n - x) - (y - 1)) > 0)
		a += (long long) w * (w + 1) / 2;
	if ((w = r - 1 - (n - x) - (n - y)) > 0)
		a += (long long) w * (w + 1) / 2;
	return a;
}

int main() {
	int n, x, y, c, lower, upper, r;

	scanf("%d%d%d%d", &n, &x, &y, &c);
	lower = -1, upper = c;
	while (upper - lower > 1) {
		r = (lower + upper) / 2;
		if (count(n, x, y, r) >= c)
			upper = r;
		else
			lower = r;
	}
	printf("%d\n", upper);
	return 0;
}