#include<bits/stdc++.h>

#define x first

#define y second

#define eps 1e-7

#define pb push_back

#define inf 0x3f3f3f3f

#define mod 1000000007

#define sq(x) ((x)*(x))

#define cb(x) ((x)*(x)*(x))

#define bit(x, y) (((x)>>(y))&1)

#define bctz(x) (__builtin_ctz(x))

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzl(x))

#define bctzl(x) (__builtin_ctzl(x))

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define pi 3.1415926535897932384626433832795

#define PQ priority_queue<pii, vector<pii>, greater<pii> >

using namespace std;

typedef double DO;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

template<typename T, typename U> inline void smin(T &a, U b) {if(a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if(a<b) a=b;}

template <class T> inline void gn(T &x) {char c, sg=0; while(c=getchar(), (c>'9' || c<'0') && c!='-'); for((c=='-' ? sg=1, c=getchar() : 0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0'; if(sg) x=-x;}

template <class T1, class T2> inline void gn(T1 &x1, T2 &x2) {gn(x1), gn(x2);}

template <class T1, class T2, class T3> inline void gn(T1 &x1, T2 &x2, T3 &x3) {gn(x1, x2), gn(x3);}

template <class T1, class T2, class T3, class T4> inline void gn(T1 &x1, T2 &x2, T3 &x3, T4 &x4) {gn(x1, x2), gn(x3, x4);}

template <class T> inline void print(T x) {if(x<0) {putchar('-'); return print(-x);} if(x<10) {putchar('0'+x); return ;} print(x/10); putchar(x%10+'0');}

template <class T> inline void println(T x) {print(x); putchar('\n');}

template <class T> inline void printsp(T x) {print(x); putchar(' ');}

template <class T1, class T2> inline void print(T1 x1, T2 x2) {printsp(x1), println(x2);}

template <class T1, class T2, class T3> inline void print(T1 x1, T2 x2, T3 x3) {printsp(x1), printsp(x2), println(x3);}

template <class T1, class T2, class T3, class T4> inline void print(T1 x1, T2 x2, T3 x3, T4 x4) {printsp(x1), printsp(x2), printsp(x3), println(x4);}

int power(int a, int b, int m, int ans=1) {

	for(; b; b>>=1, a=1LL*a*a%m) if(b&1) ans=1LL*ans*a%m;

	return ans;

}

#define NN 100010

int a[NN];

int flag[NN], sign[NN];

int main() {

#ifndef	ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	freopen("out.out", "w", stdout);

#endif

	int n;

	gn(n);

	for(int i=1; i<=n; i++) gn(a[i]);

	int sum=a[n];

	for(int i=n-1; i>=1; i--) {

		if(a[i]>sum) {

			sign[i+1]=1;

			sum=a[i]-sum;

		}

		else {

			flag[i]=1;

			sum-=a[i];

		}

	}

	int ok=0;

	for(int i=1; i<=n; i++) {

		ok^=sign[i];

		if(flag[i]^ok) putchar('-');

		else putchar('+');

	}

}


#include<iostream>
#include <string>
#include<vector>
#include <cstdio>
#include <algorithm>
#include <bitset>
#include <cmath>
using namespace std;
long long s;
int arr[10000000];
int main()
{
    long long n;
    cin >> n;
    bool f = 0;
    vector<long long>h(n);
    vector<char>u(n);
    for(int i = 0 ; i < n ; i++)
        cin >> h[i];
        for(int i = n-1;i >= 0;i--)
        {
            if(s>0)s-=h[i];
            else {arr[i]=1;s+=h[i];}
        }
         for(int i = 0;i < n;i++)if(((s>0)+arr[i])%2)cout << "-";else cout << "+";
    return 0;
}


#include<iostream>
#include <string>
#include<vector>
#include <cstdio>
#include <algorithm>
#include <bitset>
#include <cmath>
using namespace std;

int main()
{
    long long n,mx=0,sum=0;
    cin >> n;
    vector<long long>h(n);
    vector< pair<long long,long long > >k(n);
    vector<char>u(n,'+');
    for(int i = 0 ; i < n ; i++)
        {cin >> h[i];sum+=h[i];k[i].first=h[i];k[i].second=i;}
        sort(k.rbegin(),k.rend());
        for(int i = 0 ; i < n ; i++)
        while(sum > k[i].first)
        {
            sum-=k[i].first;
            u[k[i].second]='-';
        }
        for(int i = 0 ; i < n ; i++)
            cout << u[i];

    return 0;
}


#include<iostream>
#include <string>
#include<vector>
#include <cstdio>
#include <algorithm>
#include <bitset>
#include <cmath>
using namespace std;

int main()
{
    long long n,mx=0,sum=0;
    cin >> n;
    vector<long long>h(n);
    vector< pair<long long,long long > >k(n);
    vector<char>u(n,'+');
    for(int i = 0 ; i < n ; i++)
        {cin >> h[i];sum+=h[i];k[i].first=h[i];k[i].second=i;}
        sort(k.rbegin(),k.rend());
        for(int i = 0;i< n;i++)
        {
            if((sum-((k[i].first)*2)>h[0]))
            {sum-=(k[i].first*2);
                u[k[i].second]='-';}
            else if(((sum-(k[i].first*2))<=h[0])&&((sum-(k[i].first*2))>0))
            {u[k[i].second]='-';break;}
        }
        for(int i = 0 ; i < n ; i++)
            cout << u[i];

    return 0;
}


#include<iostream>
#include <string>
#include<vector>
#include <cstdio>
#include <algorithm>
#include <bitset>
#include <cmath>
using namespace std;

int main()
{
    long long n,mx=0,sum=0;
    cin >> n;
    vector<long long>h(n);
    vector< pair<long long,long long > >k(n);
    vector<char>u(n,'+');
    for(int i = 0 ; i < n ; i++)
        {cin >> h[i];sum+=h[i];k[i].first=h[i];k[i].second=i;}
        sort(k.rbegin(),k.rend());
        for(int i = 0;i< n;i++)
        {
            if((sum-((k[i].first)*2)>h[0]))
            {sum-=(k[i].first*2);
                u[k[i].second]='-';}
            if(((sum-(k[i].first*2))<=h[0])&&((sum-(k[i].first*2))>0))
            {u[k[i].second]='-';break;}
        }
        for(int i = 0 ; i < n ; i++)
            cout << u[i];

    return 0;
}


//~In The Name Of Allah~//
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <iomanip>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string.h>
#include <sstream>
#include <cstring>
#include <fstream>
#include <functional>
#include <cstdio>
#include <stack>
#include <utility>
#include <set>
#include <list>
#include <queue>
#include <bitset>
using namespace std;

#define all(S) S.begin(), S.end()
#define sortb(S) sort(all(S), greater<ll>())
#define sorta(S) sort(all(S))
#define cinp(N) cin>>N.first>>N.second
#define coutp(N) cout<<N.first<<" "<<N.second<<endl
#define mem(C, V) memset(C, V, sizeof C)
#define clr(S, V) fill(all(S), V)
#define ssum(N) ull(N*(N+1)/2)
#define gt(S) getline(cin, S)
#define sp(N) setprecision(N)<<fixed
#define sz(S) S.size()
#define mk make_pair
#define go continue
#define rep(i, j) for (ll i = 0; i < j; i++)
#define rrep(i, j) for (ll i = j - 1; i > -1; i--)
#define getdis(x1, y1, x2, y2) double(sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2)))
#define Rep(i, j, k) for (ll i = j; i < k; i++)
#define srep(C) for (decltype(C.begin()) it = C.begin(); it != C.end(); it++)
#define pi 3.1415926535897932384626433832795
#define ex 2.7182818284
#define mod 1000000007
#define oo (ll) 1e9

typedef stringstream  ss;
typedef string            s;
typedef long long       ll;
typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector<vi>      vii;
typedef vector<pii>     vpii;
typedef vector<ll>       vll;
typedef vector<bool>  vb;
typedef vector<s>       vs;
typedef map<ll, ll>      mii;
typedef map<char, ll> mci;
typedef map<s, ll>      msi;

int main(){
    //freopen("input.cpp", "r", stdin);
    //freopen("output.cpp", "w", stdout);
    ll size, tmp = 0;
    s str1 = "", str2 = "";
    scanf("%lld", &size);
    vll array(size);
    rep(i, size) scanf("%lld", &array[i]);
    rrep(i, size) if (tmp > 0) tmp -= array[i], str1 += '-', str2 += '+';
    else tmp += array[i], str1 += '+', str2 += '-';
    if (tmp > -1) reverse(all(str1)), cout << str1 << endl;
    else reverse(all(str2)), cout << str2 << endl;
    return 0;
}


#include <iostream>
#include <string>
#include <string.h>
#include <vector>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <sstream>
#include <functional>
#include <set>
#include <map>
#include <stack>
#include <utility>
#include <list>
#include <queue>
using namespace std;
int main()
{
    int size, sumtion=0;
    string result="", res="";
    cin>>size;
    vector<int> array(size);
    for (int i=0;i<size;i++) cin>>array[i];
    for (int i=size-1;i>=0;i--)
        if (sumtion>0)
            sumtion-=array[i], result+='-';
        else
            sumtion+=array[i], result+='+';
    for (int i=size-1;i>=0;i--){
        if (sumtion>0)
            res+=result[i];
        else
            if (result[i]=='-')
                res+='+';
            else
                res+='-';
    }
    cout<<res<<endl;
    return 0;
}


#include <iostream>
#include <string>
#include <string.h>
#include <vector>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <sstream>
#include <functional>
#include <set>
#include <map>
#include <stack>
#include <utility>
#include <list>
#include <queue>
using namespace std;
int main()
{
    int size, sumtion=0;
    string result="", res="";
    cin>>size;
    vector<int> array(size);
    for (int i=0;i<size;i++) cin>>array[i];
    for (int i=size-1;i>=0;i--)
        if (sumtion>0)
            sumtion-=array[i], result+='+';
        else
            sumtion+=array[i], result+='-';
    for (int i=size-1;i>=0;i--) res+=result[i];
    cout<<res<<endl;
    return 0;
}


#include <iostream>
using namespace std;
typedef long long ll;

ll sum(ll* v, int n, int* s)
{
    ll r = 0;
    for (int i = n-1; i >= 0; --i)
    {
        if (r - v[i] > 0)
            s[i] = -1, r -= v[i];
        else
        {
            r = v[i] - r;
            s[i] = 1;
            for (int j = i+1; j < n; ++j)
                s[j] = -s[j];
        }

    }

    return r;
}
int main()
{
    int s;
    cin >> s;
    ll v[100009];
    for (int i = 0; i < s; ++i)
        cin >> v[i];

    int sign[100009];
    sum(v, s, sign);

    for (int i = 0; i < s; ++i)
        cout << ((sign[i] > 0) ? '+' : '-');
    cout << endl;
}


#include <iostream>
using namespace std;
typedef long long ll;

ll sum(ll* v, int n, int* s)
{
    if (n == 0)
        return 0;

    ll r = sum(v+1, n-1, s+1);
    if (r - v[0] > 0)
        s[0] = -1;
    else
    {
        s[0] = 1;
        for (int i = 1; i < n; ++i)
            s[i] = -s[i];
    }
    return abs(r-v[0]);
}
int main()
{
    int s;
    cin >> s;
    ll v[100009];
    for (int i = 0; i < s; ++i)
        cin >> v[i];

    int sign[100009];
    sum(v, s, sign);

    for (int i = 0; i < s; ++i)
        cout << ((sign[i] > 0) ? '+' : '-');
    cout << endl;
}


#include <iostream>
using namespace std;
typedef long long ll;

ll sum(ll* v, int n, int* s)
{
    if (n == 0)
        return 0;

    ll r = sum(v+1, n-1, s+1);
    if (r - v[0] > 0)
        s[0] = -1, r -= v[0];
    else
    {
        r = v[0] - r;
        s[0] = 1;
        for (int i = 1; i < n; ++i)
            s[i] = -s[i];
    }
    return r;
}
int main()
{
    int s;
    cin >> s;
    ll v[100009];
    for (int i = 0; i < s; ++i)
        cin >> v[i];

    int sign[100009];
    sum(v, s, sign);

    for (int i = 0; i < s; ++i)
        cout << ((sign[i] > 0) ? '+' : '-');
    cout << endl;
}


#include <iostream>
using namespace std;
typedef long long ll;

ll sum(ll* v, int n, int* s)
{
    int flip[100009];

    ll r = 0;
    for (int i = n-1; i >= 0; --i)
    {
        if (r - v[i] > 0)
            s[i] = -1, r -= v[i], flip[i+1] = 0;
        else
        {
            r = v[i] - r;
            s[i] = 1;
            flip[i+1] = 1;
        }

    }
    int f = 0;
    for (int i = 0; i < n; ++i)
    {
        if (f % 2 == 1)
            s[i] = -s[i];
        f += flip[i+1];

    }
    return r;
}
int main()
{
    int s;
    cin >> s;
    ll v[100009] = {0};
    for (int i = 0; i < s; ++i)
        cin >> v[i];

    int sign[100009];
    sum(v, s, sign);

    for (int i = 0; i < s; ++i)
        cout << ((sign[i] > 0) ? '+' : '-');
    cout << endl;
}


#include <iostream>
using namespace std;
typedef long long ll;

ll sum(ll* v, int n, int* s)
{
    int flip[100009];

    ll r = 0;
    for (int i = n-1; i >= 0; --i)
    {
        if (r - v[i] > 0)
            s[i] = -1, r -= v[i], flip[i+1] = 0;
        else
        {
            r = v[i] - r;
            s[i] = 1;
            flip[i+1] = 1;
        }
        cout << flip[i+1] << " ";

    }
    int f = 0;
    for (int i = 0; i < n; ++i)
    {
        if (f % 2 == 1)
            s[i] = -s[i];
        f += flip[i+1];

    }
    return r;
}
int main()
{
    int s;
    cin >> s;
    ll v[100009] = {0};
    for (int i = 0; i < s; ++i)
        cin >> v[i];

    int sign[100009];
    sum(v, s, sign);

    for (int i = 0; i < s; ++i)
        cout << ((sign[i] > 0) ? '+' : '-');
    cout << endl;
}


#include <iostream>
using namespace std;
typedef long long ll;

ll sum(ll* v, int n, int* s)
{
    int flip[100009];

    ll r = 0;
    for (int i = n-1; i >= 0; --i)
    {
        if (r - v[i] > 0)
            s[i] = -1, r -= v[i], flip[i+1] = 0;
        else
        {
            r = v[i] - r;
            s[i] = 1;
            flip[i+1] = 1;
        }

    }
    bool f = 0;
    for (int i = 0; i < n; ++i)
    {
        f += flip[i];
        if (f % 2 == 1)
            s[i] = -s[i];

    }
    return r;
}
int main()
{
    int s;
    cin >> s;
    ll v[100009];
    for (int i = 0; i < s; ++i)
        cin >> v[i];

    int sign[100009];
    sum(v, s, sign);

    for (int i = 0; i < s; ++i)
        cout << ((sign[i] > 0) ? '+' : '-');
    cout << endl;
}


#include <bits/stdc++.h>

using namespace std;

#define maxn 100005

int n, a[maxn], d[maxn];

void nhap()
{
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
}

void cbi()
{
    memset(d, 0, sizeof(d));
}

void xuli()
{
    int t = a[n];
    for (int i = n-1; i >= 1; i--)
        if (t > 0)
        {
            t -= a[i];
            d[i] = 1;
        }
        else t += a[i];
    if (t < 0)
        for (int i = 1; i <= n; i++) d[i] = 1 - d[i];
}

void ghikq()
{
    for (int i = 1; i <= n; i++)
        if (d[i] == 0) cout << '+';
        else cout << '-';
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("inp.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    nhap();
    cbi();
    xuli();
    ghikq();
}


#include <bits/stdc++.h>

using namespace std;

#define maxn 100005

int n;
__int64 a[maxn], s[maxn];

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

void cbi()
{

}

void xuli()
{
    int t = s[n-1] - a[n];
    if (t > a[1])
    {
        int l = 0, r = distance(s+1, lower_bound(s+1, s+n+1, t));
        while ((s[r] - s[l]) * 2 > t) l++;
        for (int j = 1; j <= l; j++) cout << "+";
        for (int j = l+1; j <= r; j++) cout << "-";
        for (int j = r+1; j < n; j++) cout << "+";
    }
    else
        for (int j = 1; j < n; j++) cout << "+";
    cout << "-\n";
}

void ghikq()
{

}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("inp.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    nhap();
    cbi();
    xuli();
    ghikq();
}


#include <bits/stdc++.h>

using namespace std;

#define maxn 100005

int n, a[maxn], d[maxn];

void nhap()
{
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
}

void cbi()
{
    memset(d, 0, sizeof(d));
}

void xuli()
{
    int t = a[n];
    for (int i = n-1; i >= 1; i--)
        if (t > a[i])
        {
            t -= a[i];
            d[i] = 1;
        }
        else t += a[i];
}

void ghikq()
{
    for (int i = 1; i <= n; i++)
        if (d[i] == 0) cout << '+';
        else cout << '-';
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("inp.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    nhap();
    cbi();
    xuli();
    ghikq();
}


#include <bits/stdc++.h>

using namespace std;

#define maxn 100005

int n, a[maxn], s[maxn];

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

void cbi()
{

}

void xuli()
{
    for (int i = n; i >= 1; i--)
        if (s[i] - (s[n] - s[i]) <= a[1])
        {
            for (int j = 1; j <= i; j++) cout << "+";
            for (int j = i+1; j <= n; j++) cout << "-";
            break;
        }
}

void ghikq()
{

}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("inp.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    nhap();
    cbi();
    xuli();
    ghikq();
}


#include <bitset>
#include <cstdio>
using namespace std;

const int N = 300000009 / 2;
bitset<N> P;

int main() {
  int l, r, j;
  scanf("%d %d", &l, &r);
  P.set();
  for (int i = 3; (j = i * i) <= r; i += 2)
    if (P.test(i >> 1))
      for ( ; j <= r; j += i << 1)
        P.reset(j >> 1);
  int ans = 0;
  int i = 4;
  while (i % 4 != 1)
    i ++;
  for ( ; i <= r; i += 4)
    ans += P.test(i >> 1);
  printf("%d\n", ans + (2 >= l and 2 <= r));
}


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

bitset<300000004> P;

int main() {
  int l, r, j;
  cin >> l >> r;
  P.set();
  for (int i = 3; (j = i * i) <= r; i += 2)
    if (P[i])
      for ( ; j <= r; j += i << 1)
        P[j] = false;
  int ans = 0;
  for (int i = 5; i <= r; i += 4)
    ans += i >= l and P[i];
  cout << ans + (2 >= l and 2 <= r) << endl;
}


#include <bitset>
#include <cstdio>
using namespace std;

bitset<300000001> P;

int main() {
  int l, r, j;
  scanf("%d %d", &l, &r);
  P.set();
  for (int i = 3; (j = i * i) <= r; i += 2)
    if (P[i])
      for ( ; j <= r; j += i << 1)
        P.unset(j);
  int ans = 0;
  int i = 4;
  while (i % 4 != 1)
    i ++;
  for ( ; i <= r; i += 4)
    ans += i >= l and P[i];
  printf("%d\n", ans + (2 >= l and 2 <= r));
}


#include <bitset>
#include <cstdio>

const int N = 300000009 / 2;
std::bitset<N> P;

int main() {
  int l, r, j;
  scanf("%d %d", &l, &r);
  P.set();
  P.reset(0);
  for (int i = 3; (j = i * i) <= r; i += 2)
    if (P.test(i >> 1))
      for ( ; j <= r; j += i << 1)
        P.reset(j >> 1);
  int ans = 0;
  int i = ((l >> 2) << 2) + 1;
  if (i < l)
    i += 4;
  for ( ; i <= r; i += 4)
    ans += P.test(i >> 1);
  printf("%d\n", ans + (2 >= l and 2 <= r));
}


#include <bitset>
#include <cstdio>

const int N = 300000009 / 2;
std::bitset<N> P;

int main() {
  int l, r, j;
  scanf("%d %d", &l, &r);
  P.set();
  P.reset(0);
  for (int i = 3; (j = i * i) <= r; i += 2)
    if (P.test(i >> 1))
      for ( ; j <= r; j += i << 1)
        P.reset(j >> 1);
  int ans = 0;
  int i = ((l >> 2) << 2) ^ 1;
  if (i < l)
    i += 4;
  for ( ; i <= r; i += 4)
    ans += P.test(i >> 1);
  printf("%d\n", ans + (2 >= l and 2 <= r));
}


#include <bitset>
#include <cstdio>
using namespace std;

const int N = 300000009 / 2;
bitset<N> P;

int main() {
  int l, r, j;
  scanf("%d %d", &l, &r);
  P.set();
  for (int i = 3; (j = i * i) <= r; i += 2)
    if (P[i >> 1])
      for ( ; j <= r; j += i << 1)
        P.reset(j >> 1);
  int ans = 0;
  int i = 4;
  while (i % 4 != 1)
    i ++;
  for ( ; i <= r; i += 4)
    ans += i >= l and P[i >> 1];
  printf("%d\n", ans + (2 >= l and 2 <= r));
}


#include <bitset>
#include <cstdio>

std::bitset<150000002> P;

int main() {
  int l, r, i, j;
  scanf("%d%d", &l, &r);
  P.set();
  P.reset(0);
  int ans = 0;
  for (i = 3; (j = i * i) <= r; i += 2)
    if (P.test(i >> 1)) {
      ans += i >= l and (i & 3) == 1;
      for ( ; j <= r; j += i << 1)
        P.reset(j >> 1);
    }
  if ((i & 3) != 1)
    i += 2;
  while (i < l)
    i += 4;
  for ( ; i <= r; i += 4)
    ans += P.test(i >> 1);
  ans += (l <= 2 and 2 <= r);
  printf("%d\n", ans);
  return 0;
}


#include <cstdio>
#include <bitset>

const int N = (3*1e8+1) / 2 + 10;
std::bitset<N> s;

int main() {
  s.set(); s.reset(0);
  int l, r;
  scanf("%d%d", &l, &r);
  for (int i = 3; i * i <= r; i += 2) if (s.test(i >> 1))
    for (int j = i * i; j <= r; j += i << 1) s.reset(j >> 1);
  int resu = 0;
  int beg = ((l >> 2) << 2) ^ 1; if (beg < l) beg += 4;
  for (int i = beg; i <= r; i += 4)
    resu += s.test(i >> 1);
  resu += (l <= 2 && 2 <= r);
  printf("%d\n", resu);
  return 0;
}


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

bitset<300000004> P;

int main() {
  int l, r;
  cin >> l >> r;
  P.set();
  for (int i = 3; i * i <= r; i += 2)
    if (P[i])
      for (int j = i * i; j <= r; j += i << 1)
        P[j] = false;
  int ans = 0;
  for (int i = 5; i <= r; i += 4)
    ans += i >= l and P[i];
  cout << ans + (2 >= l and 2 <= r) << endl;
}


#include <bitset>
#include <cstdio>

const int N = 300000009 / 2;
std::bitset<N> P;

int main() {
  int l, r, j;
  scanf("%d %d", &l, &r);
  P.set();
  P.reset(0);
  for (int i = 3; (j = i * i) <= r; i += 2)
    if (P.test(i >> 1))
      for ( ; j <= r; j += i << 1)
        P.reset(j >> 1);
  int ans = 0;
  int i = l;
  while (i % 4 != 1)
    i ++;
  for ( ; i <= r; i += 4)
    ans += P.test(i >> 1);
  printf("%d\n", ans + (2 >= l and 2 <= r));
}


#include <cstdio>
#include <bitset>

const int N = (3*1e8+1) / 2 + 10;
std::bitset<N> s;

int main() {
  s.set(); s.reset(0);
  int l, r;
  scanf("%d%d", &l, &r);
  for (int i = 3; i * i <= r; i += 2) if (s.test(i >> 1))
    for (int j = i * i; j <= r; j += i << 1) s.reset(j >> 1);
  int ans = 0;
  int beg = ((l >> 2) << 2) ^ 1; if (beg < l) beg += 4;
  for (int i = beg; i <= r; i += 4)
    ans += s.test(i >> 1);
  ans += (l <= 2 && 2 <= r);
  printf("%d\n", ans);
  return 0;
}


#include <bitset>
#include <cstdio>

std::bitset<150000002> P;

int main() {
  int l, r;
  scanf("%d%d", &l, &r);
  P.set();
  P.reset(0);
  for (int i = 3; i * i <= r; i += 2)
    if (P.test(i >> 1))
      for (int j = i * i; j <= r; j += i << 1)
        P.reset(j >> 1);
  int ans = 0;
  int i = ((l >> 2) << 2) ^ 1;
  if (i < l)
    i += 4;
  for ( ; i <= r; i += 4)
    ans += P.test(i >> 1);
  ans += (l <= 2 and 2 <= r);
  printf("%d\n", ans);
  return 0;
}


#include <bitset>
#include <cstdio>
using namespace std;

const int N = 300000009 / 2;
bitset<N> P;

int main() {
  int l, r, j;
  scanf("%d %d", &l, &r);
  P.set();
  for (int i = 3; (j = i * i) <= r; i += 2)
    if (P.test(i >> 1))
      for ( ; j <= r; j += i << 1)
        P.reset(j >> 1);
  int ans = 0;
  int i = l;
  while (i % 4 != 1)
    i ++;
  for ( ; i <= r; i += 4)
    ans += P.test(i >> 1);
  printf("%d\n", ans + (2 >= l and 2 <= r));
}


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

bitset<300000004> P;

int main() {
  int l, r;
  cin >> l >> r;
  P.set();
  for (int i = 3; i * i <= r; i += 2)
    if (P[i])
      for (int j = i * i; j <= r; j += i << 1)
        P[j] = false;
  int ans = 0;
  for (int i = 5; i <= r; i += 4)
    ans += i >= l and P[i];
  cout << ans + (2 >= l) << endl;
}


#include<iostream>
#include<bitset>

using namespace std;

bitset<300000001> p;

void erastostenes(int n)
{
	p.set();
	int i,j;
	for(i=3;(j=i*i)<=n;i+=2)
		if(p[i])
			for(;j<=n;j+=i<<1)
				p[j]=false;
}

int main()
{
	int l,r;
	cin>>l>>r;
	erastostenes(r);
	if(l>r)
	{
		cout<<0<<endl;
		return 0;
	}
	int t,count=0;
	for(long long i=1;i*i<r;i++)
		for(long long j=i+1;i*i+j*j<=r;j+=2)
		{
			t=i*i+j*j;
			if(t>=l and p[t])
				count++;
		}
	if(2>=l and 2<=r)
		count++;
	cout<<count<<endl;
/*	for(int i=5;i<=r;i+=4) if(p[i]&&l<=i) count++;
	cout<<count+(l<=2 and 2<=r)<<endl;*/
	return 0;
}


#include<iostream>
#include<bitset>

using namespace std;

bitset<300000001> p;

void erastostenes(int n)
{
	p.set();
	for(int i=3;(long long)i*i<=n;i+=2)
		if(p[i])
			for(int j=i*i;j<=n;j+=i<<1)
				p[j]=false;
}

int main()
{
	int l,r;
	cin>>l>>r;
	erastostenes(r);
//	cout<<"ok"<<endl;
	if(l>r)
	{
		cout<<0<<endl;
		return 0;
	}
	int t,count=0;
	for(long long i=1;i*i<r;i++)
		for(long long j=i+1;i*i+j*j<=r;j+=2)
		{
			t=i*i+j*j;
			if(t>=l and p[t])
				count++;
		}
	if(2>=l and 2<=r)
		count++;
	cout<<count<<endl;
	return 0;
}


#include <bitset>
#include <cstdio>

std::bitset<150000002> P;

int main() {
  int l, r, j;
  scanf("%d%d", &l, &r);
  P.set();
  P.reset(0);
  for (int i = 3; (j = i * i) <= r; i += 2)
    if (P.test(i >> 1))
      for ( ; j <= r; j += i << 1)
        P.reset(j >> 1);
  int ans = 0;
  int i = ((l >> 2) << 2) ^ 1;
  if (i < l)
    i += 4;
  for ( ; i <= r; i += 4)
    ans += P.test(i >> 1);
  printf("%d\n", ans + (l <= 2 and 2 <= r));
  return 0;
}


#include<iostream>
#include<bitset>

using namespace std;

bitset<300000001> p;

void erastostenes(int n)
{
	p.set();
	int i,j;
	for(i=3;(j=i*i)<=n;i+=2)
		if(p[i])
			for(;j<=n;j+=i<<1)
				p[j]=false;
}

int main()
{
	int l,r;
	cin>>l>>r;
//	erastostenes(r);
	if(l>r)
	{
		cout<<0<<endl;
		return 0;
	}
	int t,count=0;
	for(long long i=1;i*i<r;i++)
		for(long long j=i+1;i*i+j*j<=r;j+=2)
		{
			t=i*i+j*j;
			if(t>=l/* and p[t]*/)
				count++;
		}
	if(2>=l and 2<=r)
		count++;
	cout<<count<<endl;
/*	for(int i=5;i<=r;i+=4) if(p[i]&&l<=i) count++;
	cout<<count+(l<=2 and 2<=r)<<endl;*/
	return 0;
}


#include <bitset>
#include <cstdio>
using namespace std;

const int N = 300000009 / 2;
bitset<N> P;

int main() {
  int l, r, j;
  scanf("%d %d", &l, &r);
  P.set();
  for (int i = 3; (j = i * i) <= r; i += 2)
    if (P.test(i >> 1))
      for ( ; j <= r; j += i << 1)
        P.reset(j >> 1);
  int ans = 0;
  int i = l;
  while (i == 1 or i % 4 != 1)
    i ++;
  for ( ; i <= r; i += 4)
    ans += P.test(i >> 1);
  printf("%d\n", ans + (2 >= l and 2 <= r));
}


#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <set>
#include <time.h>
#include <map>
#include <math.h>
#include <string>
#include <sstream>
#include <assert.h>
#include <queue>
#include <string.h>
#include <deque>

using namespace std;

typedef long long ll;
template<typename T> int size(T&a) {return (int)a.size(); }
template<typename T> T sqr(T a) {return a * a; }

#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define REPD(i, a, b) for(int i = (b) - 1; i >= a; --i)
#define _(a, b) memset(a, b, sizeof(a))
#define vi vector<int>
#define pii pair<int, int>
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second

const int MAXP = 300000000;
int g[MAXP/32+1];

int main() {
#ifdef air
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int l, r;
    scanf("%d%d", &l, &r);

    _(g, 255);

    int res=0, i;
    for(i=2;i*i<=r;++i){
        if(g[i>>5]&(1<<(i&31))){
            if (i >= l && i <= r) {
                if (!((i-1)&3))++res;
            }
            for(int j=i*i;j<=r;j+=i) {
                int &z=g[j>>5];
                if(z&(1<<(j&31)))
                    z^=(1<<(j&31));
            }
        }
    }
    for(;i<=r;++i){
        if (i >= l && i <= r) {
            if(g[i>>5]&(1<<(i&31))){
                if (!((i-1)&3))++res;
            }
        }
    }
    if(l<=2&&2<=r)++res;

    cout << res;

}


#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <set>
#include <time.h>
#include <map>
#include <math.h>
#include <string>
#include <sstream>
#include <assert.h>
#include <queue>
#include <string.h>
#include <deque>

using namespace std;

typedef long long ll;
template<typename T> int size(T&a) {return (int)a.size(); }
template<typename T> T sqr(T a) {return a * a; }

#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define REPD(i, a, b) for(int i = (b) - 1; i >= a; --i)
#define _(a, b) memset(a, b, sizeof(a))
#define vi vector<int>
#define pii pair<int, int>
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second

const int MAXP = 300000000;
int g[MAXP/32+1];

int main() {
#ifdef air
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int l, r;
    scanf("%d%d", &l, &r);

    _(g, 255);

    int res=0, i;
    for(i=2;i*i<=r;i=(i==2?3:i+2)){
        if(g[i>>5]&(1<<(i&31))){
            if (i >= l && i <= r) {
                if (!((i-1)&3))++res;
            }
            for(int j=i*i;j<=r;j+=i) {
                int &z=g[j>>5];
                if(z&(1<<(j&31)))
                    z^=(1<<(j&31));
            }
        }
    }
    for(;i<=r;++i){
        if (i >= l && i <= r) {
            if(g[i>>5]&(1<<(i&31))){
                if (!((i-1)&3))++res;
            }
        }
    }
    if(l<=2&&2<=r)++res;

    cout << res;

}


#include <iostream>
#include <fstream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <memory.h>
#include <map>
#include <cmath>
#include <queue>
#include <algorithm>
#include <set>

using namespace std;

const long long modulo = 1000000007;

bool re[111111];
int cnt = 0;
int my[111111];

bool good(int value)
    {
        for (int i = 1; i<=cnt; i++)
        {
            if (my[i]*my[i]>value) break;
            if (value%my[i]==0) return false;
        }
        return true;
    }

int main()
{

    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(0);
    memset(re,true,sizeof(re));
    re[1]=false;
    for (int i = 2; i*i<=100000; i++)
    {
        int j = i * i;
        if (re[i]==false) continue;
        while (j<=100000)
        {
            re[j]=false;
            j+=i;
        }
    }
    cnt = 0;
    for (int i = 2; i<=99997; i++)
         if (re[i])
    {
        cnt++;
        my[cnt]=i;
    }
    int L,R;
    cin >> L >> R;
    while (L%4!=1 && L<=R) L++;
    if (L>R)
    {
        cout << 0 << endl;
        return 0;
    }
    int ans = 0;
    while (L<=R)
    {
        if (good(L)) ans++;
        L+=4;
    }
    cout << ans << endl;
    return 0;
}


#include <iostream>
#include <fstream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <memory.h>
#include <map>
#include <cmath>
#include <queue>
#include <algorithm>
#include <set>

using namespace std;

const long long modulo = 1000000007;

bool re[111111];
int cnt = 0;
bool prime[111111111];
int my[111111];

bool good(int value)
    {
        if (value<=100000000)
        {
            return prime[value];
        }
        if (value==1) return false;
        for (int i = 1; i<=cnt; i++)
        {
            if (my[i]*my[i]>value) break;
            if (value%my[i]==0) return false;
        }
        return true;
    }

int main()
{

    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(0);
    memset(prime,true,sizeof(prime));
    prime[1]=false;
    for (int i = 2; i*i<=100000000; i++)
    {
        if (prime[i]==false) continue;
        int j = i * i;
        while (j<=100000000)
        {
            prime[j]=false;
            j+=i;
        }
    }
//    return 0;
    memset(re,true,sizeof(re));
    re[1]=false;
    for (int i = 2; i*i<=100000; i++)
    {
        int j = i * i;
        if (re[i]==false) continue;
        while (j<=100000)
        {
            re[j]=false;
            j+=i;
        }
    }
    cnt = 0;
    for (int i = 2; i<=99997; i++)
         if (re[i])
    {
        cnt++;
        my[cnt]=i;
    }
    int L,R;
    cin >> L >> R;
    while (L%4!=1 && L<=R) L++;
    if (L>R)
    {
        cout << 0 << endl;
        return 0;
    }
    int ans = 0;
    while (L<=R)
    {
        if (good(L)) ans++;
        L+=4;
    }
    cout << ans << endl;
    return 0;
}


#include <iostream>
#include <fstream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <memory.h>
#include <map>
#include <cmath>
#include <queue>
#include <algorithm>
#include <set>

using namespace std;

const long long modulo = 1000000007;

bool re[111111];
int cnt = 0;
int my[111111];

bool good(int value)
    {
        if (value==1) return false;
        for (int i = 1; i<=cnt; i++)
        {
            if (my[i]*my[i]>value) break;
            if (value%my[i]==0) return false;
        }
        return true;
    }

int main()
{

    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(0);
    memset(re,true,sizeof(re));
    re[1]=false;
    for (int i = 2; i*i<=100000; i++)
    {
        int j = i * i;
        if (re[i]==false) continue;
        while (j<=100000)
        {
            re[j]=false;
            j+=i;
        }
    }
    cnt = 0;
    for (int i = 2; i<=99997; i++)
         if (re[i])
    {
        cnt++;
        my[cnt]=i;
    }
    int L,R;
    cin >> L >> R;
    while (L%4!=1 && L<=R) L++;
    if (L>R)
    {
        cout << 0 << endl;
        return 0;
    }
    int ans = 0;
    while (L<=R)
    {
        if (good(L)) ans++;
        L+=4;
    }
    cout << ans << endl;
    return 0;
}


#include <iostream>
#include <fstream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <memory.h>
#include <map>
#include <cmath>
#include <queue>
#include <algorithm>
#include <set>

using namespace std;

const long long modulo = 1000000007;

bool re[111111];
int cnt = 0;
bool prime[111111111];
int my[111111];

bool good(int value)
    {
        if (value<=100000000)
        {
            return prime[value];
        }
        if (value==1) return false;
        for (int i = 1; i<=cnt; i++)
        {
            if (my[i]*my[i]>value) break;
            if (value%my[i]==0) return false;
        }
        return true;
    }

int main()
{

    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(0);
    memset(prime,true,sizeof(prime));
    prime[1]=false;
    for (int i = 2; i*i<=100000000; i++)
    {
        if (prime[i]==false) continue;
        int j = i * i;
        while (j<=100000000)
        {
            prime[j]=false;
            j+=i;
        }
    }
    return 0;
    memset(re,true,sizeof(re));
    re[1]=false;
    for (int i = 2; i*i<=100000; i++)
    {
        int j = i * i;
        if (re[i]==false) continue;
        while (j<=100000)
        {
            re[j]=false;
            j+=i;
        }
    }
    cnt = 0;
    for (int i = 2; i<=99997; i++)
         if (re[i])
    {
        cnt++;
        my[cnt]=i;
    }
    int L,R;
    cin >> L >> R;
    while (L%4!=1 && L<=R) L++;
    if (L>R)
    {
        cout << 0 << endl;
        return 0;
    }
    int ans = 0;
    while (L<=R)
    {
        if (good(L)) ans++;
        L+=4;
    }
    cout << ans << endl;
    return 0;
}


// =========================================================
//
//       Filename:  C.cpp
//
//    Description:
//
//        Version:  1.0
//        Created:  09/08/2011 09:38:07 AM
//       Revision:  none
//       Compiler:  g++
//
//         Author:  LI YAN (lyan), lyan@cs.ucr.edu
//        Company:  U of California Riverside
//      Copyright:  Copyright (c) 09/08/2011, LI YAN
//
// =========================================================

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

#define N 30000

int pcnt;
int primes[N];

void init()
{
    int num[N];
    for(int i=0; i<N; ++i) num[i]=1;
    num[0]=num[1]=0;
    for(int p=2; p<N; ++p)
    {
    bool isprime=true;
    for(int d=2; d*d<=p; ++d)
    {
        if (p%d==0) { isprime=false; break; }
    }
    if (isprime) primes[pcnt++]=p;
    }
}

bool isprime(int n)
{
    for(int d=2; d*d<=n; ++d)
        if (n%d==0) return false;
    return true;
}
int main()
{
    init();
    //cout << pcnt << endl;
    //for(int i=0; i<20; ++i) cout << primes[i] << ' '; cout << endl;

    int l,r; cin >> l >> r;

    int ans=0;
    for(int k=max(3,l); k<=r; ++k)
    {
        if (isprime(k) && k%4==1) ++ans;
    }

    // add 1 if 2 is in [l,r]
    if (l<=2 && 2<=r) ans++;
    cout << ans << endl;
}


// =========================================================
//
//       Filename:  C.cpp
//
//    Description:  http://codeforces.ru/contest/113/problem/C
//
//        Version:  1.0
//        Created:  09/08/2011 09:38:07 AM
//       Revision:  none
//       Compiler:  g++
//
//         Author:  LI YAN (lyan), lyan@cs.ucr.edu
//        Company:  U of California Riverside
//      Copyright:  Copyright (c) 09/08/2011, LI YAN
//
// =========================================================

#include <algorithm>
#include <bitset>
#include <iostream>
#include <vector>
using namespace std;

#define N 300000003

//bitset<N> primes;
vector<bool> primes(N);

void init()
{
    primes[0]=primes[1]=1;
    for(int k=2+2; k<=N; k+=2) primes[k]=1;
    for(int k=3; k*k<=N; k+=2) if (!primes[k])
    for(int j=k*k; j<=N; j+=2*k) primes[j]=1;
}

int main()
{
    init();

    int l,r; cin >> l >> r;
    int ans=0;
    int k;
    // Fermat's Christmas Theorem
    // if p is an odd prime
    // then p=a^2+b^2 iff p mod 4 = 1
    for(k=5; k<l; k+=4)
        ;
    for(; k<=r; k+=4)
        if (!primes[k]) ++ans;
    if (l<=2&&2<=r) ++ans;
    cout << ans << endl;
}

// 684998   Sep 9, 2011 9:35:53 AM  lantimilan  C - Double Happiness    GNU C++
// Accepted     4880 ms     38100 KB
//
// sieve of Eratosthenes
// init array 1 to N to zero (1 means not prime)
// start from 2, pick the first index that remains zero, let it be p
// mark p^2, p^2+2*p, ...
// notice that you can start from p^2 instead of 2*p because earlier ones are
// marked already
// you can do increment of 2*p instead of p because all even number are already
// marked
//
// one way to deal with memory issue is to use bitset<N>
// another way is to use vector<bool>


// =========================================================
//
//       Filename:  C.cpp
//
//    Description:  http://codeforces.ru/contest/113/problem/C
//
//        Version:  1.0
//        Created:  09/08/2011 09:38:07 AM
//       Revision:  none
//       Compiler:  g++
//
//         Author:  LI YAN (lyan), lyan@cs.ucr.edu
//        Company:  U of California Riverside
//      Copyright:  Copyright (c) 09/08/2011, LI YAN
//
// =========================================================

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

#define N 300000003

bitset<N> primes;

void init()
{
    primes[0]=primes[1]=1;
    for(int k=2+2; k<=N; k+=2) primes[k]=1;
    for(int k=3; k*k<=N; k+=2) if (!primes[k])
    for(int j=k*k; j<=N; j+=2*k) primes[j]=1;
}

int main()
{
    init();

    int l,r; cin >> l >> r;
    int ans=0;
    int k;
    // Fermat's Christmas Theorem
    // if p is an odd prime
    // then p=a^2+b^2 iff p mod 4 = 1
    for(k=5; k<l; k+=4)
        ;
    for(; k<=r; k+=4)
        if (!primes[k]) ++ans;
    if (l<=2&&2<=r) ++ans;
    cout << ans << endl;
}


// =========================================================
//
//       Filename:  C.cpp
//
//    Description:  http://codeforces.ru/contest/113/problem/C
//
//        Version:  1.0
//        Created:  09/08/2011 09:38:07 AM
//       Revision:  none
//       Compiler:  g++
//
//         Author:  LI YAN (lyan), lyan@cs.ucr.edu
//        Company:  U of California Riverside
//      Copyright:  Copyright (c) 09/08/2011, LI YAN
//
// =========================================================

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

#define N 300000003

bitset<N> primes;

void init()
{
    primes[0]=primes[1]=1;
    for(int k=3; k*k<=N; k+=2) if (!primes[k])
    for(int j=k*k; j<=N; j+=k) primes[j]=1;
}

int main()
{
    init();

    int l,r; cin >> l >> r;
    int ans=0;
    int k;
    // Fermat's Christmas Theorem
    // if p is an odd prime
    // then p=a^2+b^2 iff p mod 4 = 1
    for(k=5; k<l; k+=4)
        ;
    for(; k<=r; k+=4)
        if (!primes[k]) ++ans;
    if (l<=2&&2<=r) ++ans;
    cout << ans << endl;
}

// init takes 270ms in CF
// init takes 6s in local


// =========================================================
//
//       Filename:  C.cpp
//
//    Description:
//
//        Version:  1.0
//        Created:  09/08/2011 09:38:07 AM
//       Revision:  none
//       Compiler:  g++
//
//         Author:  LI YAN (lyan), lyan@cs.ucr.edu
//        Company:  U of California Riverside
//      Copyright:  Copyright (c) 09/08/2011, LI YAN
//
// =========================================================

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

#define N 30000

int pcnt;
int primes[N];

void init()
{
    int num[N];
    for(int i=0; i<N; ++i) num[i]=1;
    num[0]=num[1]=0;
    for(int p=2; p<N; ++p)
    {
    bool isprime=true;
    for(int d=2; d*d<=p; ++d)
    {
        if (p%d==0) { isprime=false; break; }
    }
    if (isprime) primes[pcnt++]=p;
    }
}

bool isprime(int n)
{
    for(int d=2; d*d<=n; ++d)
        if (n%d==0) return false;
    return true;
}
int main()
{
    init();
    //cout << pcnt << endl;
    //for(int i=0; i<20; ++i) cout << primes[i] << ' '; cout << endl;

    int l,r; cin >> l >> r;

    int ans=0;
    for(int k=5; k<=r; k+=4) if (l<=k)
    {
        if (isprime(k)) ++ans;
    }

    // add 1 if 2 is in [l,r]
    if (l<=2 && 2<=r) ans++;
    cout << ans << endl;
}


// =========================================================
//
//       Filename:  C.cpp
//
//    Description:
//
//        Version:  1.0
//        Created:  09/08/2011 09:38:07 AM
//       Revision:  none
//       Compiler:  g++
//
//         Author:  LI YAN (lyan), lyan@cs.ucr.edu
//        Company:  U of California Riverside
//      Copyright:  Copyright (c) 09/08/2011, LI YAN
//
// =========================================================

#include <iostream>
using namespace std;

#define N 30000
int pcnt;
int primes[N];

void init()
{
    int num[N];
    for(int i=0; i<N; ++i) num[i]=1;
    num[0]=num[1]=0;
    for(int p=2; p<N; ++p)
    {
    bool isprime=true;
    for(int d=2; d*d<=p; ++d)
    {
        if (p%d==0) { isprime=false; break; }
    }
    if (isprime) primes[pcnt++]=p;
    }
}
int main()
{
    init();
    //cout << pcnt << endl;
    //for(int i=0; i<20; ++i) cout << primes[i] << ' '; cout << endl;

    int l,r; cin >> l >> r;

    int ans=0;
    for(int i=1; i<pcnt; ++i)
    {
        int k = primes[i];
        if (l<=k && k<=r && k%4==1) ans++;
    }

    // add 1 if 2 is in [l,r]
    if (l<=2 && 2<=r) ans++;
    cout << ans << endl;
}


#include <ctime>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>

#include <algorithm>
#include <iostream>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>

using namespace std;

const bool debug = false;

const int k = 100000;

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int l, r;
	cin >> l >> r;
	int sqrtr = floor(sqrt(r + .0));
	if (debug) cerr << sqrtr << endl;
	vector<bool> prime(sqrtr, true);
	vector<int> primes;
	int answer = 0;
	for (int i = 2; i <= sqrtr; i++)
		for (int j = i * i; j <= sqrtr; j += i)
			prime[j] = false;
	for (int i = 2; i <= sqrtr; i++)
		if (prime[i])
		{
			primes.push_back(i);
			if (i >= l && i <= r && i % 4 == 1)
				answer++;
			if (debug) cerr << i << " ";
		}
	if (debug) cerr << endl;
	for (int i = sqrtr + 1; i <= r; i += k)
	{
		prime.assign(k, true);
		for (size_t j = 0; j < primes.size(); j++)
		{
			if (debug) cerr << primes[j] << ": ";
			for (int x = i % primes[j] ? primes[j] - i % primes[j] : 0; x < k; x += primes[j])
			{
				prime[x] = false;
				if (debug && x + i <= r) cerr << x << " ";
			}
			if (debug) cerr << endl;
		}
		for (int j = 0; j < k; j++)
		{
			if (debug && prime[j] && i + j <= r) cerr << i + j << " ";
			if (prime[j] && j + i >= l && j + i <= r && (j + i) % 4 == 1)
				answer++;
		}
	}
	cout << answer + (l <= 2 ? 1 : 0);
	return 0;
}


#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cstdlib>

#include <functional>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;

const int maxr = 303000000;

int l, r;
vector<bool> prime;

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cin >> l >> r;
	int root = (int) ceil(sqrt((double) r));
	prime.assign(r + 1, true);
	int answer = -1;
	if (l % 4 == 1) answer = (r - l + 1) / 4 + 1;
	if (l % 4 == 2) answer = (r - l - 2) / 4 + 1;
	if (l % 4 == 3) answer = (r - l - 1) / 4 + 1;
	if (l % 4 == 0) answer = (r - l) / 4 + 1;
	for (int i = 2; i <= root; i++)
		if (prime[i] && (i & 1))
		{
			int add = i << 2;
			for (int j = i * i; j <= r; j += add)
			{
				if (l <= j && j <= r && prime[j]) answer--;
				prime[j] = false;
			}
		}
	if (l <= 2) answer++;
	cout << answer;
	return 0;
}


#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cstdlib>

#include <functional>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;

const int maxr = 303000000;

int l, r;
bool prime[maxr + 1];

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cin >> l >> r;
	int root = (int) ceil(sqrt((double) r));
	memset(prime, true, sizeof(prime));
	int answer = -1;
	if ((r - l + 1) % 4 == 1) answer = (r - l + 1) / 4;
	if ((r - l + 1) % 4 == 2) answer = (r - l - 2) / 4;
	if ((r - l + 1) % 4 == 3) answer = (r - l - 1) / 4;
	if ((r - l + 1) % 4 == 0) answer = (r - l) / 4;
	int first =	l;
	if (l % 4 == 0) l++;
	if (l % 4 == 2) l += 3;
	if (l % 4 == 3) l += 2;
	for (int i = 2; i <= root; i++)
		if (prime[i] && (i & 1))
		{
			int add = i << 2;
			for (int j = i * i; j <= r; j += add)
			{
				if (l <= j && j <= r && prime[j]) answer--;
				prime[j] = false;
			}
		}
	cout << answer;
	return 0;
}


#include <ctime>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>

#include <algorithm>
#include <iostream>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>

using namespace std;

const bool debug = false;

const int k = 100000;

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int l, r;
	cin >> l >> r;
	int sqrtr = floor(sqrt(r + .0));
	if (debug) cerr << sqrtr << endl;
	vector<bool> prime(sqrtr, true);
	vector<int> primes;
	int answer = 0;
	for (int i = 2; i <= sqrtr; i++)
		for (int j = i * i; j <= sqrtr; j += i)
			prime[j] = false;
	for (int i = 2; i <= sqrtr; i++)
		if (prime[i])
		{
			primes.push_back(i);
			if (i >= l && i <= r && i % 4 == 1)
				answer++;
			if (debug) cerr << i << " ";
		}
	if (debug) cerr << endl;
	for (int i = sqrtr + 1; i <= r; i += k)
	{
		prime.assign(k, true);
		for (size_t j = 0; j < primes.size(); j++)
		{
			if (debug) cerr << primes[j] << ": ";
			for (int x = i % primes[j] ? primes[j] - i % primes[j] : 0; x < k; x += primes[j])
			{
				prime[x] = false;
				if (debug && x + i <= r) cerr << x << " ";
			}
			if (debug) cerr << endl;
		}
		for (int j = 0; j < k; j++)
		{
			if (debug && prime[j] && i + j <= r) cerr << i + j << " ";
			if (prime[j] && j + i >= l && j + i <= r && (j + i) % 4 == 1)
				answer++;
		}
	}
	cout << answer;
	return 0;
}


#include <ctime>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>

#include <algorithm>
#include <iostream>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>

using namespace std;

const bool debug = false;

const int k = 100000;

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int l, r;
	cin >> l >> r;
	int sqrtr = floor(sqrt(r + .0));
	if (debug) cerr << sqrtr << endl;
	vector<bool> prime(sqrtr, true);
	vector<int> primes;
	int answer = 0;
	for (int i = 2; i <= sqrtr; i++)
		for (int j = i * i; j <= sqrtr; j += i)
			prime[j] = false;
	for (int i = 2; i <= sqrtr; i++)
		if (prime[i])
		{
			primes.push_back(i);
			if (i >= l && i <= r && i % 4 == 1)
				answer++;
			if (debug) cerr << i << " ";
		}
	if (debug) cerr << endl;
	for (int i = sqrtr + 1; i <= r; i += k)
	{
		prime.assign(k, true);
		for (size_t j = 0; j < primes.size(); j++)
		{
			if (debug) cerr << primes[j] << ": ";
			for (int x = i % primes[j] ? primes[j] - i % primes[j] : 0; x < k; x += primes[j])
			{
				prime[x] = false;
				if (debug && x + i <= r) cerr << x << " ";
			}
			if (debug) cerr << endl;
		}
		for (int j = 0; j < k; j++)
		{
			if (debug && prime[j] && i + j <= r) cerr << i + j << " ";
			if (prime[j] && j + i >= l && j + i <= r && (j + i) % 4 == 1)
				answer++;
		}
	}
	if (l <= 2 && 2 <= r) answer++;
	cout << answer;
	return 0;
}


#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cstdlib>

#include <functional>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;

const int maxr = 303000000;

int l, r;
vector<bool> prime;

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cin >> l >> r;
	int root = (int) ceil(sqrt((double) r));
	prime.assign(r + 1, true);
	int answer = -1;
	if ((r - l + 1) % 4 == 1) answer = (r - l + 1) / 4;
	if ((r - l + 1) % 4 == 2) answer = (r - l - 2) / 4;
	if ((r - l + 1) % 4 == 3) answer = (r - l - 1) / 4;
	if ((r - l + 1) % 4 == 0) answer = (r - l) / 4;
	int first =	l;
	if (l % 4 == 0) l++;
	if (l % 4 == 2) l += 3;
	if (l % 4 == 3) l += 2;
	for (int i = 2; i <= root; i++)
		if (prime[i] && (i & 1))
		{
			int add = i << 2;
			for (int j = i * i; j <= r; j += add)
			{
				if (l <= j && j <= r && prime[j]) answer--;
				prime[j] = false;
			}
		}
	if (l <= 2) answer++;
	cout << answer;
	return 0;
}


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

using namespace std;

const int inf = 1000000001;

typedef long long LL;

string s1, s2, t;
bool e1[4009], e2[4009];
LL h[2009][2009];

int main()
{
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    cin >> t;
    cin >> s1;
    cin >> s2;
    for (int i = 0; i < (int)t.size(); i++)
    {
        if (t.substr(i, (int)s1.size()) == s1)
            e1[i] = true;
        else
            e1[i] = false;
    }
    for (int i = 0; i < (int)t.size(); i++)
    {
        if (t.substr(i, (int)s2.size()) == s2)
            e2[i + (int)s2.size() - 1] = true;
        else
            e2[i + (int)s2.size() - 1] = false;
    }
    for (int i = 0; i < (int)t.size(); i ++)
    {
        LL hh = 0;
        for (int j = i; j < (int)t.size(); j++)
        {
            hh = hh * LL(31) + LL(t[j] - 'a');
            h[i][j] = hh;
        }
    }
    set<string> s;
    set<LL> hs;
    int ans = 0;
    for (int l = int(max(s1.size(), s2.size())); l <= (int)t.size(); l++)
    {
        s.clear();
        hs.clear();
        for (int i = 0; i + l - 1 < (int)t.size(); i++)
        {
            if (e1[i] == true && e2[i + l - 1] == true)
            {
                if (hs.find(h[i][i + l - 1]) == hs.end())
                {
                    s.insert(t.substr(i, l));
                    hs.insert(h[i][i + l - 1]);
                }
            }
        }
        ans += int(s.size());
    }
    cout << ans << endl;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <bitset>
using namespace std;

int l,r,res,j;
bitset <300000001> prime;

int main () {
	scanf("%d%d",&l,&r);
	prime.set();
	for(int i=3;(j = i*i) <= r; i += 2)  if(prime[i]){
		for(;j<=r;j+=(i<<1))
			prime[j] = false;
	}
	for(int i=5;i<=r;i+=4) {
		if(prime[i]  &&  l <= i)  res++;
	}
	if(l <= 2  &&  r >= 2)  res++;
	printf("%d",res);
	return 0;
}


#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <string>
#include <cstdlib>
#include <vector>
#include <map>
#include <set>
#include <ctime>
#include <cassert>
#include <queue>
using namespace std;
#define f first
#define s second

long long l,r;
int res;
unsigned int mask[10000000];

int main () {
	#ifdef LOCAL
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif

	scanf("%I64d%I64d",&l,&r);

	for(long long i=3ll;i<=r;i+=2) {
		if(!(mask[i>>5]&(1<<((i&31)-1)))) {
			for(long long j=3*i;j<=r;j+=2*i) if(!(mask[j>>5]&(1<<((j&31)-1)))) {
				mask[j>>5] += (1<<((j&31)-1));
			}
		}
	}
	mask[0] += 1;
	for(int i=0;i<=r/32+1;++i) {
		for(int j=0;j<32;j+=4) if((i*1ll<<5) + j + 1 >= l  && (i*1ll<<5) + j + 1 <= r){
			if(!(mask[i]&(1<<j))) res++;
		}
	}
	printf("%d",res);
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <ctime>
using namespace std;

int l,r,res,j;
bitset <300000002> prime;

int main () {
	double t1 = clock();
	#ifdef LOCAL
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	scanf("%d%d",&l,&r);
	prime.set();
	for(int i=3;(j = i*i) <= r; i += 2)  if(prime[i]){
		for(;j<=r;j+=(i<<1))
			prime[j] = false;
	}
	for(int i=5;i<=r;i+=4) {
		if(prime[i]  &&  l <= i)  res++;
	}
	if(l <= 2  &&  r >= 2)  res++;
	printf("%d",res);
//	printf("\n\n%.9lf\n",(clock() - t1)/CLOCKS_PER_SEC);
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <bitset>
using namespace std;

int l,r,res,j;
bitset <300000002> prime;

int main () {
	scanf("%d%d",&l,&r);
	prime.set();
	for(int i=3;(j = i*i) <= r; i += 2)  if(prime[i]){
		for(;j<=r;j+=(i<<1))
			prime[j] = false;
	}
	for(int i=5;i<=r;i+=4) {
		if(prime[i]  &&  l <= i)  res++;
	}
	if(l <= 2  &&  r >= 2)  res++;
	printf("%d",res);
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <bitset>
using namespace std;

int l,r,res,j;
bitset <300000001> prime;

int main () {
	scanf("%d%d",&l,&r);
	for(int i=3;(j = i*i) <= r; i += 2)  if(!prime[i]){
		for(;j<=r;j+=(i<<1))
			prime[j] = true;
	}
	for(int i=5;i<=r;i+=4) {
		if(!prime[i]  &&  l <= i)  res++;
	}
	if(l <= 2  &&  r >= 2)  res++;
	printf("%d",res);
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <bitset>
using namespace std;

int l,r;
int res;
bitset <300000001> prime;

int main () {
	#ifdef LOCAL
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif

	scanf("%d%d",&l,&r);
	prime.set();
	for(int i=3;i*i <= r; i += 2)  if(prime[i]){
		for(int j = i*i;j<=r;j+=(1<<i)
			prime[j] = false;
	}
	for(int i=5;i<=r;i+=4) {
			if(prime[i]  &&  l <= i)  res++;
	}
	if(l <= 2  &&  r >= 2)  res++;
	printf("%d",res);
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <bitset>
using namespace std;

int l,r,res,j;
bitset <300000001> prime;

int main () {
	scanf("%d%d",&l,&r);
	for(int i=3;i <= r; i += 2)  if(!prime[i]){
		for(j=3*i;j<=r;j+=(i<<1))
			prime[j] = true;
	}
	for(int i=5;i<=r;i+=4) {
		if(!prime[i]  &&  l <= i)  res++;
	}
	if(l <= 2  &&  r >= 2)  res++;
	printf("%d",res);
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#define MAXN 20000
using namespace std;
bool ISP[MAXN],result[300000000/4+10];
int prime[MAXN];
int is_prime()
{
    int p=0;
    ISP[0]=ISP[1]=1;
    for (int i=1; i<=MAXN; i++)
        if (ISP[i]==0)
        {
            prime[p++]=i;
            for (int j=i+i; j<=MAXN; j+=i)
                ISP[j]=1;
        }
    return p-1;
}
int cnt(int L,int R)
{
    int p=is_prime();
    for (int j=0; j<=p; j++)
    {
        int x=L/prime[j];
        if (x*prime[j]<L) x++;
        if (x==1) x++;
        for (int k=x*prime[j]; k<=R; k+=prime[j])
               if (k%4==1) result[(k-1)/4]=1;
    }
    int cnt=0;
    for (int i=L;i<=R;i+=4)
        if (!result[(i-1)/4]) cnt++;
    return cnt;
}
int main()
{
    is_prime();
    int L,R;
    cin>>L>>R;
    while (L%4!=1||L==1)
        L++;
    while (R%4!=1)
        R--;
    int max=(R-L)/4;
    cout<<cnt(L,R);
    return 0;
}


#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <bitset>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <list>
#include <map>
#include <set>
using namespace std;
/***************************************/
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<string> VS;
typedef set<int> SI;
typedef set<string> SS;
typedef map<int ,int> MII;
typedef map<string,int> MSI;
typedef pair<int,int> PII;
typedef vector<PII> VII;
typedef vector<VI > VVI;
/***************************************/
#define clr(a,b) memset(a,b,sizeof(a))
#define all(x)	(x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define ll long long
#define int64 __int64
#define pb push_back
#define mp make_pair
#define LL(x) ((x)<<1)
#define RR(x) ((x)<<1|1)
#define ri(x) scanf("%d",&x)
#define rii(x,y) scanf("%d%d",&x,&y)
#define rd(x) scanf("%lf",&x)
#define rdd(x,y) scanf("%lf%lf",&x,&y)
#define rs(x) scanf("%s",x)
#define pi(x) printf("%d",x)
#define pin(x) printf("%d\n",x)
#define ps(x) printf("%s",x)
#define pn()  printf("\n")
#define sqr(x) ((x)*(x))
#define rep(i,a,b)  for(int i=(a);i<(b);i++)
#define repu(i,a,b) for(int i=(a);i<=(b);i++)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define repc(i,a,c) for(int i=(a);(c);i++)
/***************************************/
const int INF = 0x7f7f7f7f;
const double eps = 1e-8;
const double PIE=acos(-1.0);
const int dx[]= {0,1,0,-1};
const int dy[]= {1,0,-1,0};
const int fx[]= {-1,-1,-1,0,0,1,1,1};
const int fy[]= {-1,0,1,-1,1,-1,0,1};
/***************************************/
void openfile()
{
    freopen("data.in","rb",stdin);
    freopen("data.out","wb",stdout);
}
/**********************The End OF The Template*****************/

const int N = 17500;
const int MOD = 10000009;
short isprime[N];
int prime[N],cnt;
short vis[MOD];

int hashcode(int n)
{
	int key=1;
	while(n)
	{
        key=(key*29+n%10)%MOD;
        n/=10;
    }
	return key;
}

void init()
{
    isprime[0]=isprime[1]=true;
    cnt=0;
    rep(i,2,N)
    {
        if(isprime[i]==false)
            prime[cnt++]=i;
        for(int j=0; j<cnt&&i*prime[j]<N; j++)
        {
            isprime[i*prime[j]]=1;
            if(i%prime[j]==0)
                break;
        }
    }
}

int solve(int l,int r)
{
    int total=0;
    for(int i=0; i<cnt; i++)
    {
        int x=l/prime[i];
        if(x*prime[i]<l)
            x++;
        if(x==1) x++;
        for(int j=x*prime[i]; j<=r; j+=prime[i])
        {
            int Hash=hashcode((j-1)/4);
            if(j%4==1&&vis[Hash]==0)
            {
                vis[Hash]=1;
                total++;
            }
        }
    }
    return (r-l)/4-total+1;
}

int main()
{
    int l,r;
    init();
    rii(l,r);
    int ans=0;
    if(r==1)
    {
        pin(0);
        return 0;
    }
    if(l<=2&&r>=2)	ans++;
    while(l%4!=1||l==1)
        l++;
    while(r%4!=1)
        r--;
    if(l>r)
    {
        pin(ans);
        return 0;
    }
    ans+=solve(l,r);
    pin(ans);
    return 0;
}


#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <bitset>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <list>
#include <map>
#include <set>
using namespace std;
/***************************************/
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<string> VS;
typedef set<int> SI;
typedef set<string> SS;
typedef map<int ,int> MII;
typedef map<string,int> MSI;
typedef pair<int,int> PII;
typedef vector<PII> VII;
typedef vector<VI > VVI;
/***************************************/
#define clr(a,b) memset(a,b,sizeof(a))
#define all(x)	(x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define ll long long
#define int64 __int64
#define pb push_back
#define mp make_pair
#define LL(x) ((x)<<1)
#define RR(x) ((x)<<1|1)
#define ri(x) scanf("%d",&x)
#define rii(x,y) scanf("%d%d",&x,&y)
#define rd(x) scanf("%lf",&x)
#define rdd(x,y) scanf("%lf%lf",&x,&y)
#define rs(x) scanf("%s",x)
#define pi(x) printf("%d",x)
#define pin(x) printf("%d\n",x)
#define ps(x) printf("%s",x)
#define pn()  printf("\n")
#define sqr(x) ((x)*(x))
#define rep(i,a,b)  for(int i=(a);i<(b);i++)
#define repu(i,a,b) for(int i=(a);i<=(b);i++)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define repc(i,a,c) for(int i=(a);(c);i++)
/***************************************/
const int INF = 0x7f7f7f7f;
const double eps = 1e-8;
const double PIE=acos(-1.0);
const int dx[]= {0,1,0,-1};
const int dy[]= {1,0,-1,0};
const int fx[]= {-1,-1,-1,0,0,1,1,1};
const int fy[]= {-1,0,1,-1,1,-1,0,1};
/***************************************/
void openfile()
{
    freopen("data.in","rb",stdin);
    freopen("data.out","wb",stdout);
}
/**********************The End OF The Template*****************/

const int N = 17500;
short isprime[N];
int prime[N],cnt;
bitset<N*N/4>mymap;

void init()
{
    isprime[0]=isprime[1]=true;
    cnt=0;
    rep(i,2,N)
    {
        if(isprime[i]==false)
            prime[cnt++]=i;
        for(int j=0; j<cnt&&i*prime[j]<N; j++)
        {
            isprime[i*prime[j]]=1;
            if(i%prime[j]==0)
                break;
        }
    }
}

int solve(int l,int r)
{
    int total=0;
    for(int i=0; i<cnt; i++)
    {
        int x=l/prime[i];
        if(x*prime[i]<l)
            x++;
        if(x==1) x++;
        for(int j=x*prime[i]; j<=r; j+=prime[i])
        {
            if(j%4==1&&mymap[(j-1)/4]==0)
            {
                mymap[(j-1)/4]=1;
                total++;
            }
        }
    }
    return (r-l)/4-total+1;
}

int main()
{
    int l,r;
    init();
    rii(l,r);
    int ans=0;
    if(r==1)
    {
        pin(0);
        return 0;
    }
    if(l<=2&&r>=2)	ans++;
    while(l%4!=1||l==1)
    {
        l++;
    }
    while(r%4!=1)
    {
        r--;
    }
    if(l>r)
    {
        pin(ans);
        return 0;
    }
    ans+=solve(l,r);
    pin(ans);
    return 0;
}


#include<stdio.h>
#include<iostream>
#include<string.h>
#define clr(x) memset(x,0,sizeof(x));
#define MAXN 300000000
using namespace std;
char a[MAXN/4+10];
int main()
{
    int i,j;
    clr(a);
    a[0]=a[1]=1;
    for(i=0; i<=MAXN/4; i++)
    {
        if(a[i]==0)
            for(j=i+i; j<=MAXN/4; j+=i)
            {
                a[j]=1;
            }
    }
    for(i=0; i<=MAXN/4; i++)
        if(a[i]==0)
        {
            if(i%4!=1)
                a[i]=1;
        }
    a[2]=0;
    int x,y,ans=0;
    cin >> x >> y;
    for(i=x; i<=y; i++)
        if(a[i]==0)
        {
            ans++;
        }
    cout << ans << endl;
    return 0;
}


#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <bitset>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <list>
#include <map>
#include <set>
#define MAXN 17500
using namespace std;
//bool ISP[MAXN];
bitset<300000000/4+10>result;
bitset<MAXN> ISP;
int prime[MAXN];
int is_prime(int L)
{
    int p=0;
    ISP[0]=ISP[1]=1;
    for (int i=1; i<=L; i++)
        if (ISP[i]==0)
        {
            prime[p++]=i;
            for (int j=i+i; j<=L; j+=i)
                ISP[j]=1;
        }
    return p-1;
}
int cnt(int L,int R)
{
    is_prime(L);
    int p=is_prime(L);
    for (int j=0; j<=p; j++)
    {
        int x=L/prime[j];
        if (x*prime[j]<L) x++;
        if (x==1) x++;
        for (int k=x*prime[j]; k<=R; k+=prime[j])
            if (k%4==1) result[(k-1)/4]=1;
    }
    int cnt=0;
    for (int i=L; i<=R; i+=4)
        if (!result[(i-1)/4]) cnt++;
    return cnt;
}
int main()
{
    int L,R;
    int ok=0;
    cin>>L>>R;
    if (L<=2&&R>=2) ok=1;
    while (L%4!=1||L==1)
        L++;
    while (R%4!=1)
        R--;
    int max=(R-L)/4;
    cout<<cnt(L,R)+ok;
    return 0;
}


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

using namespace std;

#define ll long long

const int K = 32;

const int MN = (3 * 10000 * 10000 + 50) / K + 5;

int prime[MN];

inline void xr(int &x, int k) {
	x ^= (1 << k);
}

inline bool is_set(int x, int k) {
	return (x & (1 << k));
}

int lf, rg, ans = 0;

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin >> lf >> rg;
	fill(&prime[0], &prime[0] + MN, (1 << (K - 1)) - 1);
	xr(prime[0], 0);
	xr(prime[0], 1);
	for(int i = 2; i <= rg; i ++) {
		if (is_set(prime[i >> K], i % K)) {
			if ((ll)i * i <= (ll)rg) {
				for(int j = i * i; j <= rg; j += i)
					if (is_set(prime[j >> K], j % K))
						xr(prime[j >> K], j % K);
			}
			if (i >= lf && (i - 1) % 4 == 0) {
				//cout << i << endl;
				ans ++;
			}
		}
	}
	cout << ans;
	return 0;
}


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

using namespace std;

#define ll long long

const int MN = (int)3e8 + 5;

unsigned char nonprime[MN / 8 + 5];

int lf, rg, ans = 0;

inline void set_bit(int i) {
	int x = i & 7;
	nonprime[i >> 3] |= (1 << x);
}

inline bool is_set(int i) {
	int x = i & 7;
	return nonprime[i >> 3] & (1 << x);
}

int main() {
	 //freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin >> lf >> rg;
	if (lf <= 2 && 2 <= rg)
		ans ++;
	for(int i = 3; i * i <= rg; i += 2) {
		if (!is_set(i)) {
			for(int j = i * i; j <= rg; j += 2*i)
				set_bit(j);
		}
	}
	for(int i = 5; i <= rg; i += 4)
		if (i >= lf && i <= rg && !is_set(i))
			ans ++;
	cout << ans;
	return 0;
}


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

using namespace std;

#define ll long long

const int K = 3;

const int MN = (int)3e8 + 10;

unsigned char nonprime[MN / K];

int lf, rg, ans = 0;

inline void set_bit(int i) {
	int x = (i - (i >> K) * (1 << K));
	nonprime[i >> K] |= (1 << x);
}

inline bool is_set(int i) {
	int x = (i - (i >> K) * (1 << K));
	return nonprime[i >> K] & (1 << x);
}

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin >> lf >> rg;
	set_bit(1);
	for(int i = 2; i <= rg; i ++) {
		if (!is_set(i) && (ll)i * i <= rg)
			for(int j = i * i; j <= rg; j += i)
				set_bit(j);
	}
	for(int i = 5; i <= rg; i += 4)
		if (i >= lf && i <= rg && !is_set(i))
			ans ++;
	cout << ans;
	return 0;
}


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

using namespace std;

#define ll long long

const int MN = (int)3e8 + 5;

unsigned char nonprime[MN / 8 + 5];

int lf, rg, ans = 0;

inline void set_bit(int i) {
	int x = i & 7;
	nonprime[i >> 3] |= (1 << x);
}

inline bool is_set(int i) {
	int x = i & 7;
	return nonprime[i >> 3] & (1 << x);
}

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin >> lf >> rg;
	if (lf <= 2 && 2 <= rg)
		ans ++;
	for(int i = 3; i * i <= rg; i += 2) {
		if (!is_set(i))
			for(int j = i * i; j <= rg; j += 2*i)
				set_bit(j);
	}
	for(int i = 5; i <= rg; i += 4)
		if (i >= lf && i <= rg && !is_set(i))
			ans ++;
	cout << ans;
	return 0;
}


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

using namespace std;

#define ll long long

const int MN = (int)3e8 + 5;

unsigned char nonprime[MN / 8 + 5];

int lf, rg, ans = 0;

inline void set_bit(int i) {
	int x = i & 7;
	nonprime[i >> 3] |= (1 << x);
}

inline bool is_set(int i) {
	int x = i & 7;
	return nonprime[i >> 3] & (1 << x);
}

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin >> lf >> rg;
	if (lf <= 2 && 2 <= rg)
		ans ++;
	for(int i = 3; i * i <= rg; i += 2) {
		if (!is_set(i)) {
			for(int j = i * i; j <= rg; j += 2*i)
				set_bit(j);
		}
	}
	for(int i = 5; i <= rg; i += 4)
		if (i >= lf && i <= rg && !is_set(i))
			ans ++;
	cout << ans;
	return 0;
}


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

using namespace std;

#define ll long long

const int K = 31;

const int MN = (3 * 10000 * 10000 + 50) / K + 5;

int prime[MN];

void xr(int &x, int k) {
	x ^= (1 << k);
}

inline bool is_set(int x, int k) {
	return (x & (1 << k));
}

int lf, rg, ans = 0;

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin >> lf >> rg;
	fill(&prime[0], &prime[0] + MN, (1 << K) - 1);
	xr(prime[0], 0);
	xr(prime[0], 1);
	for(int i = 2; i <= rg; i ++) {
		if (is_set(prime[i / K], i % K)) {
			if ((ll)i * i <= (ll)rg) {
				for(int j = i * i; j <= rg; j += i)
					if (is_set(prime[j / K], j % K))
						xr(prime[j / K], j % K);
			}
			if (i >= lf && (i - 1) % 4 == 0) {
				//cout << i << endl;
				ans ++;
			}
		}
	}
	cout << ans;
	return 0;
}


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

using namespace std;

#define ll long long

const int K = 32;

const int MN = (3 * 10000 * 10000 + 50) / K + 5;

int prime[MN];

inline void xr(int &x, int k) {
	x ^= (1 << k);
}

inline bool is_set(int x, int k) {
	return (x & (1 << k));
}

int lf, rg, ans = 0;

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin >> lf >> rg;
	fill(&prime[0], &prime[0] + MN, (1 << (K - 1)) - 1);
	xr(prime[0], 0);
	xr(prime[0], 1);
	for(int i = 2; i <= rg; i ++) {
		if (is_set(prime[i >> K], i - (i >> K))) {
			if ((ll)i * i <= (ll)rg) {
				for(int j = i * i; j <= rg; j += i)
					if (is_set(prime[j >> K], j - (j >> K)))
						xr(prime[j >> K], j - (j >> K));
			}
			if (i >= lf && (i - 1) % 4 == 0) {
				//cout << i << endl;
				ans ++;
			}
		}
	}
	cout << ans;
	return 0;
}


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

using namespace std;

#define ll long long

const int K = 3;

const int MN = (int)3e8 + 10;

unsigned char nonprime[MN / (1 << K)];

int lf, rg, ans = 0;

inline void set_bit(int i) {
	int x = (i - (i >> K) * (1 << K));
	nonprime[i >> K] |= (1 << x);
}

inline bool is_set(int i) {
	int x = (i - (i >> K) * (1 << K));
	return nonprime[i >> K] & (1 << x);
}

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin >> lf >> rg;
	set_bit(1);
	for(int i = 3; i * i <= rg; i += 2) {
		if (!is_set(i))
			for(int j = i * i; j <= rg; j += i)
				set_bit(j);
	}
	for(int i = 5; i <= rg; i += 4)
		if (i >= lf && i <= rg && !is_set(i))
			ans ++;
	cout << ans;
	return 0;
}


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

#define DEBUG 0

#if (DEBUG == 1)
    #define debug(fmt, ...) fprintf(stderr, fmt, ##__VA_ARGS__)
#else
    #define debug(fmt, ...)
#endif

#define INFTY 2000000000

using namespace std;

typedef pair<int,int> pint;
typedef long long int lint;

#define MAXN 300000000
#define MAXSQ 20000
vector<bool> sito(MAXN, false);
vector<int> good;

int main()
{
    good.push_back(2);
    for (int i=2; i<sito.size(); i++) {
        if (!sito[i] && i<MAXSQ)
            for (int j=i*i; j<sito.size(); j += i)
                sito[j] = true;
        if (!sito[i] && i%4==1) good.push_back(i);
    }

    // return 0;

    int A, B;
    scanf("%d %d", &A, &B);
    int i1 = lower_bound(good.begin(), good.end(), A) - good.begin(),
        i2 = upper_bound(good.begin(), good.end(), B) - good.begin();

    printf("%d\n", i2-i1);

    return 0;
}


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

#define DEBUG 0

#if (DEBUG == 1)
    #define debug(fmt, ...) fprintf(stderr, fmt, ##__VA_ARGS__)
#else
    #define debug(fmt, ...)
#endif

#define INFTY 2000000000

using namespace std;

typedef pair<int,int> pint;
typedef long long int lint;

#define MAXN 300000000
#define MAXSQ 18000

int main()
{
    int A, B;
    scanf("%d %d", &A, &B);

    int M = max(A,B)+1;
    vector<bool> sito(M, false);
    vector<int> good;

    good.push_back(2);
    for (int i=2; i<sito.size(); i+=(i==2?1:2)) {
        if (!sito[i] && i<MAXSQ)
            for (int j=i*i; j<sito.size(); j += i)
                sito[j] = true;
        if (!sito[i] && i%4==1) good.push_back(i);
    }

    int i1 = lower_bound(good.begin(), good.end(), A) - good.begin(),
        i2 = upper_bound(good.begin(), good.end(), B) - good.begin();

    printf("%d\n", i2-i1);

    return 0;
}


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

#define DEBUG 0

#if (DEBUG == 1)
    #define debug(fmt, ...) fprintf(stderr, fmt, ##__VA_ARGS__)
#else
    #define debug(fmt, ...)
#endif

#define INFTY 2000000000

using namespace std;

typedef pair<int,int> pint;
typedef long long int lint;

#define MAXN 300000000
#define MAXSQ 18000

int main()
{
    int A, B;
    scanf("%d %d", &A, &B);

    int M = max(A,B)+1;
    vector<bool> sito(M, false);
    vector<int> good;

    good.push_back(2);
    for (int i=2,di=(i==2?1:2); i<sito.size(); i+=di) {
        if (!sito[i] && i<MAXSQ)
            for (int j=i*i,dj=(i==2?1:2); j<sito.size(); j += dj*i)
                sito[j] = true;
        if (!sito[i] && i%4==1) good.push_back(i);
    }

    int i1 = lower_bound(good.begin(), good.end(), A) - good.begin(),
        i2 = upper_bound(good.begin(), good.end(), B) - good.begin();

    printf("%d\n", i2-i1);

    return 0;
}


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

#define DEBUG 0

#if (DEBUG == 1)
    #define debug(fmt, ...) fprintf(stderr, fmt, ##__VA_ARGS__)
#else
    #define debug(fmt, ...)
#endif

#define INFTY 2000000000

using namespace std;

typedef pair<int,int> pint;
typedef long long int lint;

#define MAXN 300000000
#define MAXSQ 18000

int main()
{
    int A, B;
    scanf("%d %d", &A, &B);

    int M = max(A,B)+1;
    vector<bool> sito(M, false);
    vector<int> good;

    good.push_back(2);
    for (int i=2; i<sito.size(); i+=(i==2?1:2)) {
        bool s = sito[i];
        if (!s && i<MAXSQ)
            for (int j=i*i,dj=(i==2?1:2); j<sito.size(); j += ((j>MAXSQ && j%4==1)?2*dj:dj)*i)
                sito[j] = true;
        if (!s && i%4==1) good.push_back(i);
    }

    int i1 = lower_bound(good.begin(), good.end(), A) - good.begin(),
        i2 = upper_bound(good.begin(), good.end(), B) - good.begin();

    printf("%d\n", i2-i1);

    return 0;
}


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

#define DEBUG 0

#if (DEBUG == 1)
    #define debug(fmt, ...) fprintf(stderr, fmt, ##__VA_ARGS__)
#else
    #define debug(fmt, ...)
#endif

#define INFTY 2000000000

using namespace std;

typedef pair<int,int> pint;
typedef long long int lint;

#define MAXN 300000000
#define MAXSQ 18000
vector<bool> sito(MAXN, false);
vector<int> good;

int main()
{
    good.push_back(2);
    for (int i=2; i<sito.size(); i+=(i==2?1:2)) {
        if (!sito[i] && i<MAXSQ)
            for (int j=i*i; j<sito.size(); j += i)
                sito[j] = true;
        if (!sito[i] && i%4==1) good.push_back(i);
    }

    // return 0;

    int A, B;
    scanf("%d %d", &A, &B);
    int i1 = lower_bound(good.begin(), good.end(), A) - good.begin(),
        i2 = upper_bound(good.begin(), good.end(), B) - good.begin();

    printf("%d\n", i2-i1);

    return 0;
}


/*************************************************************************
    > File Name: 113C.cpp
    > Author: Stomach_ache
    > Mail: sudaweitong@gmail.com
    > Created Time: 2014年07月20日 星期日 13时34分53秒
    > Propose:
 ************************************************************************/

#include <cmath>
#include <string>
#include <bitset>
#include <cstdio>
#include <fstream>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

const int maxn = 1e8+1e8+1e8;
bitset<maxn> p;

int
main(void) {
  	int L, R;
  	scanf("%d %d\n", &L, &R);
	p.set();
	for (int i = 3; i*i <= R; i+=2) if (p[i]) for (int j = i*i; j <= R; j+=2*i) p[j] = false;
	int ans = 0;
	for (int i = 5; i <= R; i+=4) if (p[i] && i >= L) ans++;
	ans += (L <= 2 && R >= 2) ? 1 : 0;
	printf("%d\n", ans);

	return 0;
}


#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <bitset>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <list>
#include <map>
#include <set>
#define MAXN 17500
using namespace std;
bool ISP[MAXN];
bitset<300000000/4+10>result;
int prime[MAXN];
int is_prime(int L)
{
    int p=0;
    ISP[0]=ISP[1]=1;
    for (int i=1; i<=L; i++)
        if (ISP[i]==0)
        {
            prime[p++]=i;
            for (int j=i+i; j<=L; j+=i)
                ISP[j]=1;
        }
    return p-1;
}
int cnt(int L,int R)
{
    is_prime(L);
    int p=is_prime(L);
    for (int j=0; j<=p; j++)
    {
        int x=L/prime[j];
        if (x*prime[j]<L) x++;
        if (x==1) x++;
        for (int k=x*prime[j]; k<=R; k+=prime[j])
            if (k%4==1) result[(k-1)/4]=1;
    }
    int cnt=0;
    for (int i=L; i<=R; i+=4)
        if (!result[(i-1)/4]) cnt++;
    return cnt;
}
int main()
{
    int L,R;
    int ok=0;
    cin>>L>>R;
    if (L<=2&&R>=2) ok=1;
    while (L%4!=1||L==1)
        L++;
    while (R%4!=1)
        R--;
    int max=(R-L)/4;
    cout<<cnt(L,R)+ok;
    return 0;
}


#include<string>
#include<iostream>
#include<stdio.h>
#define MAXN 300000000/4
using namespace std;
bool a[MAXN+10];
int  b[MAXN+10],c[MAXN+10];
int is_prime()
{
   int i,j;
   a[0]=a[1]=1;
   for (i=2;i<=MAXN;i++)
        if (a[i]==0)
            for (j=i*2;j<=MAXN;j+=i)
                a[j]=1;
    int cnt1=0,cnt2=0;
    for (i=1;i<=MAXN;i++)
    {
        if ((i%4==1&&a[i]==0)||i==2) cnt1++;
        if (a[i]==0) cnt2++;
        b[i]=cnt1;
        c[i]=cnt2;
    }
}
int main()
{
    int l,r;
    is_prime();
    while (1)
    {
        cin>>l>>r;
        if (l==-1&&r==-1) break;
        printf("%d %d %d %d\n",l,r,c[r]-c[l-1],b[r]-b[l-1]);
    }
    return 0;
}


/*************************************************************************
    > File Name: 113C.cpp
    > Author: Stomach_ache
    > Mail: sudaweitong@gmail.com
    > Created Time: 2014年07月20日 星期日 13时34分53秒
    > Propose:
 ************************************************************************/

#include <cmath>
#include <string>
#include <bitset>
#include <cstdio>
#include <fstream>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

const int maxn = 1e8+1e8+1e8;
bitset<maxn> p;

int
main(void) {
  	int L, R;
  	scanf("%d %d\n", &L, &R);
	p.set();
	for (int i = 3; i*i <= R; i+=2) if (p[i]) for (int j = i*i; j <= R; j+=i) p[j] = false;
	int ans = 0;
	for (int i = 5; i <= R; i+=4) if (p[i] && i >= L) ans++;
	ans += (L <= 2 && R >= 2) ? 1 : 0;
	printf("%d\n", ans);

	return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=300000000;
bool flag[maxn/4+10];
int prime[20000],vs[20000],pl;
void _prime(int n)
{
    for(int i=2; i<=n; i++)
    {
        if(!vs[i]) prime[pl++]=i;
        for(int j=0; j<pl&&i*prime[j]<=n; j++)
        {
            vs[i*prime[j]]=1;
            if(i%prime[j]==0) break;
        }
    }
}
int initprime(int l,int r)
{
    int ans=0;
    if(l<=2&&r>=2) ans++;
    while(l%4!=1||l==1) l++;
    int sqt=(int)sqrt(0.5+r);
    _prime(sqt);
    for(int i=0; i<pl; i++)
    {
        int g=l/prime[i];
        if(g<2) g=2;
        int j=g*prime[i];
        for(; j<=r; j+=prime[i])
        {
            if(j%4==1)//将%4=1的合数删去,剩下的就是%4=1的素数
            {
                flag[j>>2]=1;
            }
        }
    }
    for(int i=l; i<=r; i+=4)
    {
        if(!flag[i>>2]) ans++;
    }
    return ans;
}
int main()
{
    int l,r;
    scanf("%d%d",&l,&r);
    int ans=initprime(l,r);
    printf("%d\n",ans);
    return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include <iostream>
#include<algorithm>
using namespace std;
int main()
{
    char a[100];
    char byte1[100]="127";
    char short1[100]="32767";
    char int1[100]="2147483647";
    char long1[100]="9223372036854775807";
    char byte2[100]="0128";
    char short2[100]="032768";
    char int2[100]="02147483648";
    char long2[100]="09223372036854775808";
    int i,j,len;
    while(gets(a)!=NULL)
    {
        int flag=0;
        if(a[0]!='-')
        {
            len=strlen(a);
            if(len<3)
                flag=1;
            else if(len==3)
            {
                for(i=0; i<3; i++)
                {
                    if(a[i]>byte1[i])
                        break;
                    if(a[i]<byte1[i])
                    {
                        flag=1;
                        break;
                    }
                }
                if(i==3||flag==1)
                {
                    flag=1;
                }
                else
                    flag=2;
            }
            else if(len<5)
                flag=2;
            else if(len==5)
            {
                for(i=0; i<5; i++)
                {
                    if(a[i]>short1[i])
                        break;
                    if(a[i]<short1[i])
                    {
                        flag=2;
                        break;
                    }
                }
                if(i==5||flag==2)
                    flag=2;
                else
                    flag=3;
            }
            else if(len<10)
                flag=3;
            else if(len==10)
            {
                for(i=0; i<10; i++)
                {
                    if(a[i]>int1[i])
                        break;
                    if(a[i]<int1[i])
                    {
                        flag=3;
                        break;
                    }
                }
                if(i==10||flag==3)
                    flag=3;
                else
                    flag=4;
            }
            else if(len<19)
                flag=4;
            else if(len==19)
            {
                for(i=0; i<19; i++)
                {
                    if(a[i]>long1[i])
                        break;
                    if(a[i]<long1[i])
                    {
                        flag=4;
                        break;
                    }
                }
                if(i==19||flag==4)
                    flag=4;
            }
            else
                flag=5;
        }
        if(a[0]=='-')
        {
            len=strlen(a);
            if(len<4)
                flag=1;
            else if(len==4)
            {
                for(i=1; i<4; i++)
                {
                    if(a[i]>byte2[i])
                        break;
                    if(a[i]<byte2[i])
                    {
                        flag=1;
                        break;
                    }
                }
                if(i==4)
                {
                    flag=1;
                }
                else
                    flag=2;
            }
            else if(len<6)
                flag=2;
            else if(len==6)
            {
                for(i=1; i<6; i++)
                {
                    if(a[i]>short2[i])
                        break;
                    if(a[i]<short2[i])
                    {
                        flag=2;
                        break;
                    }
                }
                if(i==6)
                    flag=2;
                else
                    flag=3;
            }
            else if(len<11)
                flag=3;
            else if(len==11)
            {
                for(i=1; i<11; i++)
                {
                    if(a[i]>int2[i])
                        break;
                    if(a[i]<int2[i])
                    {
                        flag=3;
                        break;
                    }
                }
                if(i==11)
                    flag=3;
                else
                    flag=4;
            }
            else if(len<20)
                flag=4;
            else if(len==20)
            {
                for(i=1; i<20; i++)
                {
                    if(a[i]>long2[i])
                        break;
                    if(a[i]<long2[i])
                    {
                        flag=4;
                        break;
                    }
                }
                if(i==20)
                    flag=4;
            }
            else
                flag=5;
        }
        if(flag==1)
            puts("byte");
        else if(flag==2)
            puts("short");
        else if(flag==3)
            puts("int");
        else if(flag==4)
            puts("long");
        else
            puts("BigInteger");
    }
    return 0;
}


#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<limits.h>
#define MAXN 300000000
using namespace std;
bool a[MAXN+10];
void is_prime()
{
    a[0]=a[1]=1;
    for (int i=2;i<=MAXN;i++)
    {
        if (a[i]==0)
            for (int j=i+i;j<=MAXN;j+=i)
                a[j]=1;
    }
    int cnt=0;
    for (int i=1;i<=MAXN;i++)
    {
        if ((a[i]==0&&i%4==1)||i==2) a[i]=1;
        else a[i]=0;
    }
}
int main()
{
    is_prime();
    int m,n,cnt=0;
    cin>>m>>n;
    for (int i=m;i<=n;i++)
    {
        if (a[i]) cnt++;
    }
    printf("%d",cnt);
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=300000000;
bool flag[maxn/4+10];
int prime[20000],vs[20000],pl;
void _prime(int n)
{
    for(int i=2;i<=n;i++)
    {
        if(!vs[i]) prime[pl++]=i;
        for(int j=0;j<pl&&i*prime[j]<=n;j++)
        {
            vs[i*prime[j]]=1;
            if(i%prime[j]==0) break;
        }
    }
}
int initprime(int l,int r)
{
    int ans=0;
    if(l<=2&&r>=2) ans++;
    while(l%4!=1||l==1) l++;
    int sqt=(int)sqrt(0.5+r);
    _prime(sqt);
    for(int i=0;i<pl;i++)
    {
        int g=l/prime[i];
        if(g<2) g=2;
        int j=g*prime[i];
        for(;j<=r;j+=prime[i])
        {
            if(j%4==1)//将%4=1的合数删去,剩下的就是%4=1的素数
            {
                flag[j>>2]=1;
            }
        }
    }
    for(int i=l;i<=r;i+=4)
    {
        if(!flag[i>>2]) ans++;
    }
    return ans;
}
int main()
{
    int l,r;
    scanf("%d%d",&l,&r);
    int ans=initprime(l,r);
    printf("%d\n",ans);
    return 0;
}


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

using namespace std;

const int MAXN = 8125718 + 2;

vector<bool> v;
//vector<int> p, q;
int p[MAXN], pn = 0;
int l, r;
int thr = 200000000;

int main() {
	//freopen("in", "r", stdin);
	//freopen("out", "w", stdout);
	cin >> l >> r;
	v.resize(r + 1);
	v[1] = 1;
	v[2] = 0;

	for (int i = 3 ; i*i <= r ; i += 2) {
		if (!v[i]) {
			for (int j = i * i ; j <= r ; j += i)
				v[j] = 1;
			//cout << i << endl;
			/*
			if ((i & 3) == 1)
				p.push_back(i);*/
		}
	}
	p[pn ++] = 2;
	for (int i = 4*( (l-2)/4 + 1) + 1 ; i <= r ; i += 4) {
		if (((i & 3) == 1) && !v[i]) {
			p[pn ++] = i;
		}
	}
	//cout << p.size() << endl;
	int indr = upper_bound(p, p + pn, r) - p;
	int indl = lower_bound(p, p + pn, l) - p;

	//cout << indr << ' ' << indl << endl;
	cout << indr - indl << endl;

	return 0;
}


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

using namespace std;

vector<bool> v;
vector<long long> p;
long long l, r;

int main() {
	cin >> l >> r;
	v.resize(r + 1);
	v[1] = 1;
	v[2] = 0;

	for (long long i = 3 ; i*i <= r ; i += 2) {
		if (!v[i]) {
			for (long long j = i * i ; j <= r ; j += i)
				v[j] = 1;
			//cout << i << endl;
			/*
			if ((i & 3) == 1)
				p.push_back(i);*/
		}
	}
	for (long long i = 4*(l/4) + 1 ; i <= r ; i += 4)
		if (!v[i] && ((i & 3) == 1) && i >= l)
			p.push_back(i);
	int indr = upper_bound(p.begin(), p.end(), r) - p.begin();
	int indl = lower_bound(p.begin(), p.end(), l) - p.begin();

	//cout << indr << ' ' << indl << endl;
	cout << indr - indl << endl;

	return 0;
}


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

using namespace std;

const int MAXN = 8125718 + 2;

//vector<int> p, q;
int p[MAXN], pn = 0;
int l, r;

const int magic = (1 << 6) - 1;

long long bs[(int)3e8/64 + 5];

inline bool get(int i) {
	return (bs[i >> 6] & (1ll << (i & magic)));
}

inline void set1(int i) {
	bs[i >> 6] |= 1ll << (i & magic);
}

int main() {
	//freopen("in", "r", stdin);
	//freopen("out", "w", stdout);
	cin >> l >> r;
	/*
	v.resize(r + 1);
	v[1] = 1;
	v[2] = 0;
	*/

	set1(1);

	for (int i = 3 ; i*i <= r ; i += 2) {
		if (!get(i)) {
			for (int j = i * i ; j <= r ; j += i)
				set1(j);
			//cout << i << endl;
			/*
			if ((i & 3) == 1)
				p.push_back(i);*/
		}
	}
	p[pn ++] = 2;
	for (int i = 4*( (l-2)/4 + 1) + 1 ; i <= r ; i += 4) {
		if (((i & 3) == 1) && !get(i)) {
			p[pn ++] = i;
			//cout << i << endl;
		}
	}
	//cout << p.size() << endl;
	int indr = upper_bound(p, p + pn, r) - p;
	int indl = lower_bound(p, p + pn, l) - p;

	//cout << indr << ' ' << indl << endl;
	cout << indr - indl << endl;

	return 0;
}


#include <iostream>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <bitset>

using namespace std;

const int MAXN = 8125718 + 2;
const int thr = 300000002;

//bitset<thr> v;
vector<bool> v;
//vector<int> p, q;
int p[MAXN], pn = 0;
int l, r;

int main() {
	//freopen("in", "r", stdin);
	//freopen("out", "w", stdout);
	cin >> l >> r;
	v.resize(r + 1);
	v[1] = 1;
	v[2] = 0;

	for (int i = 3 ; i*i <= r ; i += 2) {
		if (!v[i]) {
			for (int j = i * i ; j <= r ; j += 2*i)
				v[j] = 1;
			//cout << i << endl;
			/*
			if ((i & 3) == 1)
				p.push_back(i);*/
		}
	}
	p[pn ++] = 2;
	for (int i = 4*( (l-2)/4 + 1) + 1 ; i <= r ; i += 4) {
		if (((i & 3) == 1) && !v[i]) {
			p[pn ++] = i;
		}
	}
		int indr = upper_bound(p, p + pn, r) - p;
	int indl = lower_bound(p, p + pn, l) - p;

	//cout << indr << ' ' << indl << endl;
	cout << indr - indl << endl;

	return 0;
}


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

using namespace std;

vector<bool> v;
vector<long long> p;
long long l, r;

int main() {
	cin >> l >> r;
	v.resize(r + 1);
	v[1] = 1;
	v[2] = 0;
	for (long long i = 3 ; i*i <= r ; i += 2) {
		if (!v[i]) {
			for (long long j = i + i ; j <= r ; j += i)
				v[j] = 1;
			//cout << i << endl;
			/*
			if ((i & 3) == 1)
				p.push_back(i);*/
		}
	}
	for (long long i = 4*(l/4) + 1 ; i <= r ; i += 4)
		if (!v[i] && ((i & 3) == 1) && i >= l)
			p.push_back(i);
	int indr = upper_bound(p.begin(), p.end(), r) - p.begin();
	int indl = lower_bound(p.begin(), p.end(), l) - p.begin();

	//cout << indr << ' ' << indl << endl;
	cout << indr - indl << endl;

	return 0;
}


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

using namespace std;

vector<bool> v;
vector<long long> p;
long long l, r;

int main() {
	cin >> l >> r;
	v.resize(r + 1);
	v[1] = 1;
	v[2] = 0;

	for (long long i = 3 ; i*i <= r ; i += 2) {
		if (!v[i]) {
			for (long long j = i * i ; j <= r ; j += i)
				v[j] = 1;
			//cout << i << endl;
			/*
			if ((i & 3) == 1)
				p.push_back(i);*/
		}
	}
	for (long long i = 4*(l/4) + 1 ; i <= r ; i += 4)
		if (((i & 3) == 1) && !v[i] && i >= l)
			p.push_back(i);
	int indr = upper_bound(p.begin(), p.end(), r) - p.begin();
	int indl = lower_bound(p.begin(), p.end(), l) - p.begin();

	//cout << indr << ' ' << indl << endl;
	cout << indr - indl << endl;

	return 0;
}


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

using namespace std;

vector<bool> v;
vector<int> p;
int l, r;

int main() {
	cin >> l >> r;
	v.resize(r + 1);
	v[1] = 1;
	v[2] = 0;

	for (int i = 3 ; i*i <= r ; i += 2) {
		if (!v[i]) {
			for (int j = i * i ; j <= r ; j += i)
				v[j] = 1;
			//cout << i << endl;
			/*
			if ((i & 3) == 1)
				p.push_back(i);*/
		}
	}
	for (int i = 4*(l/4) + 1 ; i <= r ; i += 4)
		if (((i & 3) == 1) && !v[i] && i >= l)
			p.push_back(i);
	//cout << p.size() << endl;
	int indr = upper_bound(p.begin(), p.end(), r) - p.begin();
	int indl = lower_bound(p.begin(), p.end(), l) - p.begin();

	//cout << indr << ' ' << indl << endl;
	cout << indr - indl << endl;

	return 0;
}


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

using namespace std;

const int MAXN = 10000000;

vector<bool> v;
int p[MAXN], pn = 0;
int l, r;
int thr = 200000000;

int main() {
	//freopen("in", "r", stdin);
	//freopen("out", "w", stdout);
	cin >> l >> r;
	v.resize(r + 1);
	v[1] = 1;
	v[2] = 0;

	for (int i = 3 ; i*i <= r ; i += 2) {
		if (!v[i]) {
			for (int j = i * i ; j <= r ; j += i)
				v[j] = 1;
			//cout << i << endl;
			/*
			if ((i & 3) == 1)
				p.push_back(i);*/
		}
	}
	p[pn ++] = 2;
	for (int i = 4*(l/4) + 1 ; i <= r ; i += 4) {
		if (((i & 3) == 1) && !v[i] && i >= l) {
			p[pn ++] = i;
		}
	}
	//cout << p.size() << endl;
	int indr = upper_bound(p, p + pn, r) - p;
	int indl = lower_bound(p, p + pn, l) - p;

	//cout << indr << ' ' << indl << endl;
	cout << indr - indl << endl;

	return 0;
}


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

using namespace std;

const int MAXN = 10000000;

vector<bool> v;
//vector<int> p, q;
int p[MAXN], pn = 0;
int l, r;
int thr = 200000000;

int main() {
	//freopen("in", "r", stdin);
	//freopen("out", "w", stdout);
	cin >> l >> r;
	v.resize(r + 1);
	v[1] = 1;
	v[2] = 0;

	for (int i = 3 ; i*i <= r ; i += 2) {
		if (!v[i]) {
			for (int j = i * i ; j <= r ; j += i)
				v[j] = 1;
			//cout << i << endl;
			/*
			if ((i & 3) == 1)
				p.push_back(i);*/
		}
	}
	for (int i = 4*(l/4) + 1 ; i <= r ; i += 4) {
		if (((i & 3) == 1) && !v[i] && i >= l) {
			p[pn ++] = i;
		}
	}
	//cout << p.size() << endl;
	int indr = upper_bound(p, p + pn, r) - p;
	int indl = lower_bound(p, p + pn, l) - p;

	//cout << indr << ' ' << indl << endl;
	cout << indr - indl << endl;

	return 0;
}


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

using namespace std;

vector<bool> v;
vector<int> p;
int l, r;

int main() {
	cin >> l >> r;
	v.resize(r + 1);
	v[1] = 1;
	v[2] = 0;

	for (int i = 3 ; i*i <= r ; i += 2) {
		if (!v[i]) {
			for (int j = i * i ; j <= r ; j += i)
				v[j] = 1;
			//cout << i << endl;
			/*
			if ((i & 3) == 1)
				p.push_back(i);*/
		}
	}
	for (int i = 4*(l/4) + 1 ; i <= r ; i += 4)
		if (((i & 3) == 1) && !v[i] && i >= l)
			p.push_back(i);
	cout << p.size() << endl;
	int indr = upper_bound(p.begin(), p.end(), r) - p.begin();
	int indl = lower_bound(p.begin(), p.end(), l) - p.begin();

	//cout << indr << ' ' << indl << endl;
	cout << indr - indl << endl;

	return 0;
}


#define  _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<map>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<stack>
#include<math.h>
#include<set>
#include<string>
#include<cstring>
#include<queue>
#include<complex>
#include<math.h>
#include<memory.h>
#include<sstream>
#include<cstdio>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define repi(i,a,n) for(int i=a;i<n;i++)
#define inf (0x7fffffff)
#define mp make_pair
#define fastIO ios::sync_with_stdio(false)
#define read freopen("in.in","r",stdin)
#define write freopen("out.out","w",stdout)
#define scf(xx) scanf("%d",&xx)
#define All(a) a.begin(), a.end()

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

void print(int a[],int n){
    rep(i,n)cout<<a[i]<<" ";
    cout<<endl;
}

ll a,b,n;
ll l,t,m;
bool can(ll mid){
    ll sum1=((mid*(mid-1))/2);
    ll sum2=((l*(l-1))/2);
    ll sum=sum1-sum2;
    sum*=b;
    sum+=(mid-l+1)*a;
    if( a+ b*(mid-1)  > t)return 0;
    return sum <= m*t;
}

int main(){
    fastIO;
   //    read;
    cin>>a>>b>>n;
    while(n--){
        cin>>l>>t>>m;
        ll lft=l ,r=1000000000 , res=-1 , mid;
        while( lft<= r){
            mid=(lft+r)>>1;
            if( can (mid )) res=mid , lft=mid+1;
            else r=mid-1;
        }
        cout<<res<<endl;
    }
    return 0;
}


#define  _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<map>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<stack>
#include<math.h>
#include<set>
#include<string>
#include<cstring>
#include<queue>
#include<complex>
#include<math.h>
#include<memory.h>
#include<sstream>
#include<cstdio>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define repi(i,a,n) for(int i=a;i<n;i++)
#define inf (0x7fffffff)
#define mp make_pair
#define fastIO ios::sync_with_stdio(false)
#define read freopen("in.in","r",stdin)
#define write freopen("out.out","w",stdout)
#define scf(xx) scanf("%d",&xx)
#define All(a) a.begin(), a.end()

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

void print(int a[],int n){
    rep(i,n)cout<<a[i]<<" ";
    cout<<endl;
}

ll a,b,n;
ll l,t,m;
bool can(ll mid){
    ll sum1=((mid*(mid+1))/2)*b;
    ll sum2=((l*(l-1))/2)*b;
    ll sum=sum1-sum2;
    if( a+ b*(mid-1)  > t)return 0;
    return sum <= m*t;
}

int main(){
    fastIO;
    //read;
    cin>>a>>b>>n;
    while(n--){
        cin>>l>>t>>m;
        ll lft=l ,r=1000000000 , res=-1 , mid;
        while( lft<= r){
            mid=(lft+r)>>1;
            if( can (mid )) res=mid , lft=mid+1;
            else r=mid-1;
        }
        cout<<res<<endl;
    }
    return 0;
}