143165576
 1919020031
 1204252996
 210637432
 724264821
 1741
 619489590
 1199537418
 1075765759
 747976826
 638486017
 58438190
 1285316221
 186925426
 1180540990
 833393692
 1818960378
 2000000000
 0
 1309028227
 514714359
 624205168
 1795248373
 643201595
 1304312649

14 3 3 4 5 2 4 4 2 4 6 4 3 4 5 3 5 4 1 5 3 4 5 5 8
#include <bits/stdc++.h>
using namespace std;
long long int INF = 1e18;
const int N = 600331;
vector<int> comp;
int colored[N];
vector<int> g[N];
void dfs(int v) {
  comp.push_back(v);
  colored[v] = 1;
  for (long long int i = 0; i < g[v].size(); i++) {
    long long int to = g[v][i];
    if (colored[to]) continue;
    dfs(to);
  }
}
long long int lcm(long long int a, long long int b) {
  long long int m, n;
  m = a;
  n = b;
  while (m != n) {
    if (m < n)
      m = m + a;
    else
      n = n + b;
  }
  return m;
}
void cal() {
  string week[] = {"sun", "mon", "tue", "wed", "thu", "fri", "sat"};
  long long int year, days;
  cin >> year;
  days = 365 * year + (year - 1) / 4 - (year - 1) / 100 + (year - 1) / 400;
  cout << week[days % 7] << endl;
}
long long int palin(long long int x) {
  long long int t = x, y = 0;
  while (t > 0) {
    long long int rem = t % 10;
    y = y * 10 + rem;
    t /= 10;
  }
  if (x == y)
    return 1;
  else
    return 0;
}
bool f(char ch1, char ch2) {
  if (tolower(ch1) != tolower(ch2)) {
    return tolower(ch1) < tolower(ch2);
  }
  return ch1 < ch2;
}
int main() {
  ios ::sync_with_stdio(0);
  cin.tie(0);
  cout << (fixed) << setprecision(9);
  long long int i, t, mini = 1e9, t1, maxi = -1e9, sum = 0, a[201201] = {0}, b,
                      dp[501][501];
  long long int j, m, n, rem = 0, d, o, c = 0, min, max, k, a1[201121], f = 0,
                         x, y;
  map<int, int> make_pair;
  string s;
  cin >> n;
  while (n > 0) {
    rem = n % 10;
    m = m + rem;
    n /= 10;
  }
  if (m >= 28)
    cout << m % 21;
  else
    cout << m % 7;
  return 0;
}
