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

int main()
{
  int ans = 0;
  int max;
  string s10, s8;
  cin >> max;
  for (long long i = 1; i <= max; i++)
  {
    stringstream ss1, ss2;
    ss1 << dec << i;
    s10 = ss1.str();
    ss2 << oct << i;
    s8 = ss2.str();
    long unsigned int s10pos7 = s10.find('7');
    long unsigned int s8pos7 = s8.find('7');
    if (s10pos7 == string::npos && s8pos7 == string::npos)
      ans++;
  }
  cout << ans << endl;
}
#include <bits/stdc++.h>

#define ms(a,b) memset(a, b, sizeof(a))
#define rep(a,b,c) for(int a = (int)(b); a < (int)(c); a++)
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define m_p(a,b) make_pair(a, b)
#define lson l,mid,o << 1
#define rson mid + 1,r,o << 1 | 1
#define ls o << 1
#define rs o << 1 | 1
#define inf 0x3f3f3f3f

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;

inline bool isdigit(char& ch) {
	return ch >= '0' && ch <= '9';
}
template<class T>
void read(T &x) {
	x = 0;
	ll f = 1;char ch = getchar();
	for (;!isdigit(ch);ch = getchar()) 
		if (ch == '-') f = -1;
	for (; isdigit(ch);ch = getchar())
		x = (x << 1) + (x << 3) + ch - '0';
	x *= f;
}
template<class T>
inline void write(T x) {
	if (x == 0) {putchar('0');return ;}
	if (x < 0) {putchar('-');x = -x;}
	int _stk[65],_top = 0;
	for (;x;x /= 10) _stk[++_top] = x % 10 + 48;
	for (;_top;_top--)putchar(_stk[_top]);
}

const int MAXN = 1e5 + 10;

int n;
ll arr[MAXN];

int main () {
	read(n);
	ll mi = 1e10;
	ll g;
	rep(i, 1, n + 1) {
		read(arr[i]);
		if (i == 1)
			g = arr[i];
		else
			g = __gcd(arr[i], g);
		mi = min(arr[i], mi);
	}
	cout << g;
	return 0;
}