#include <bits/stdc++.h>
using namespace std;
struct SuffixArray {
  long long n, k;
  string S;
  vector<long long> sa, lcp;
  SuffixArray() {}
  SuffixArray(string S) : S(S) { init(); }
  void init() {
    n = S.length();
    sa.clear();
    lcp.clear();
    sa.resize(n + 1, 0);
    lcp.resize(n + 1, 0);
    build_sa();
  }
  void build_sa() {
    S.push_back('$');
    vector<long long> c(n + 1, 0), ord(n + 1, 0);
    for (long long i = 0; i <= n; i++) ord[i] = n - i;
    sort(ord.begin(), ord.end(),
         [&](long long a, long long b) { return S[a] < S[b]; });
    return;
    for (long long i = 0; i <= n; i++) {
      sa[i] = ord[i];
      c[i] = S[i];
    }
    for (long long len = 1; len <= n; len *= 2) {
      vector<long long> r = c;
      for (long long i = 0; i <= n; i++) {
        c[sa[i]] = i > 0 && r[sa[i - 1]] == r[sa[i]] && sa[i - 1] + len <= n &&
                           r[sa[i - 1] + len / 2] == r[sa[i] + len / 2]
                       ? c[sa[i - 1]]
                       : i;
      }
      vector<long long> cnt(n + 1);
      for (long long i = 0; i <= n; i++) cnt[i] = i;
      vector<long long> s = sa;
      for (long long i = 0; i <= n; i++) {
        long long s1 = s[i] - len;
        if (s1 >= 0) sa[cnt[c[s1]]++] = s1;
      }
    }
    S.pop_back();
  }
  bool contains(string T) {
    long long a = 0, b = n + 1;
    while (a + 1 < b) {
      long long c = (a + b) / 2;
      if (S.compare(sa[c], T.length(), T) < 0)
        a = c;
      else
        b = c;
    }
    if (b == n + 1) b--;
    return S.compare(sa[b], T.length(), T) == 0;
  }
  long long count(string T) {
    long long sl = S.length(), tl = T.length();
    long long a[2], b[2];
    for (long long i = 0; i < 2; i++) {
      a[i] = 0;
      b[i] = sl;
      while (a[i] + 1 < b[i]) {
        long long c = (a[i] + b[i]) / 2;
        if (S.compare(sa[c], tl, T) < 0 || (i && S.compare(sa[c], tl, T) == 0))
          a[i] = c;
        else
          b[i] = c;
      }
    }
    if (S.compare(sa[b[0]], tl, T) != 0) return 0;
    if (a[1] < sl && S.compare(sa[a[1] + 1], tl, T) == 0) a[1]++;
    if (b[0] > 0 && S.compare(sa[b[0] - 1], tl, T) == 0) b[0]--;
    return a[1] - b[0] + 1;
  }
  void build_lcp() {
    vector<long long> r2(n);
    for (long long i = 0; i < n; i++) r2[sa[i]] = i;
    long long h = 0;
    lcp[0] = 0;
    for (long long i = 0; i < n; i++) {
      long long j = sa[r2[i] - 1];
      if (h > 0) h--;
      for (; j + h < n && i + h < n; h++) {
        if (S[j + h] != S[i + h]) break;
      }
      lcp[r2[i] - 1] = h;
    }
  }
  long long getlcp(long long p, string& T, long long d) {
    long long i = 0;
    long long len =
        min((long long)T.length() - d, (long long)S.length() - p - d);
    while (i < len && S[p + d + i] == T[d + i]) i++;
    return i;
  }
  struct RMQ {
    long long n;
    vector<long long> dat;
    const long long def = INT_MAX;
    RMQ() {}
    RMQ(long long n_) { init(n_); }
    RMQ(long long n_, vector<long long>& a) {
      init(n_);
      build(n_, a);
    }
    void init(long long n_) {
      n = 1;
      while (n < n_) n *= 2;
      dat.clear();
      dat.resize(2 * n - 1, def);
    }
    void build(long long n_, vector<long long>& a) {
      for (long long i = 0; i < n_; i++) dat[i + n - 1] = a[i];
      for (long long i = n - 2; i >= 0; i--)
        dat[i] = min(dat[i * 2 + 1], dat[i * 2 + 2]);
    }
    void update(long long k, long long a) {
      k += n - 1;
      dat[k] = a;
      while (k > 0) {
        k = (k - 1) / 2;
        dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
      }
    }
    long long query(long long a, long long b, long long k, long long l,
                    long long r) {
      if (r <= a || b <= l) return def;
      if (a <= l && r <= b)
        return dat[k];
      else {
        long long vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
        long long vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
        return min(vl, vr);
      }
    }
    long long query(long long a, long long b) { return query(a, b, 0, 0, n); }
  };
  RMQ rmq;
  void build_rmq() {
    rmq.init(n);
    rmq.build(n, lcp);
  }
  long long count2(string T) {
    long long a[2], b[2];
    long long sl = S.length(), tl = T.length();
    for (long long i = 0; i < 2; i++) {
      long long p, l, r;
      p = tl;
      a[i] = 0;
      b[i] = sl;
      l = getlcp(sa[a[i]], T, 0);
      r = getlcp(sa[b[i]], T, 0);
      while (a[i] + 1 < b[i]) {
        long long c = (a[i] + b[i]) / 2;
        if (l >= r) {
          long long m = rmq.query(a[i], c);
          if (m < l)
            b[i] = c, r = m;
          else {
            long long k = l + getlcp(sa[c], T, l);
            if (i) {
              if (k == p || S[sa[c] + k] < T[k])
                a[i] = c, l = k;
              else
                b[i] = c, r = k;
            } else {
              if (k == p)
                b[i] = c, r = k;
              else if (S[sa[c] + k] < T[k])
                a[i] = c, l = k;
              else
                b[i] = c, r = k;
            }
          }
        } else {
          long long m = rmq.query(c, b[i]);
          if (m < r)
            a[i] = c, l = m;
          else {
            long long k = r + getlcp(sa[c], T, r);
            if (i) {
              if (k == p || S[sa[c] + k] < T[k])
                a[i] = c, l = k;
              else
                b[i] = c, r = k;
            } else {
              if (k == p)
                b[i] = c, r = k;
              else if (S[sa[c] + k] < T[k])
                a[i] = c, l = k;
              else
                b[i] = c, r = k;
            }
          }
        }
      }
    }
    if (a[1] < sl && getlcp(sa[a[1] + 1], T, 0) == tl) a[1]++;
    if (b[0] > 0 && getlcp(sa[b[0] - 1], T, 0) == tl) b[0]--;
    if (getlcp(sa[b[0]], T, 0) != tl) return 0;
    return a[1] - b[0] + 1;
  }
};
char buf[1000001];
signed main() {
  scanf("%s", buf);
  string T(buf);
  SuffixArray sa(T);
  return 0;
  long long q;
  scanf("%lld", &q);
  while (q--) {
    scanf("%s", buf);
    string P(buf);
    printf("%lld\n", (long long)sa.contains(P));
  }
  return 0;
}
