#include <bits/stdc++.h>
using namespace std;
const long long int INF = (1LL << 60) - 1;
const long long int MAX = 2000001;
long long int fast_exp(long long int base, long long int exp, long long int m) {
  long long int res = 1;
  while (exp > 0) {
    if (exp % 2 == 1) {
      res = (res * base) % m;
    }
    base = (base * base) % m;
    exp /= 2;
  }
  return res % m;
}
int main() {
  ios ::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  long long int n = s.length(), ans = 0, res1, res2;
  if (n == 1) {
    if ((s[0] - '0') % 4 == 0) {
      cout << 1 << endl;
      return 0;
    } else {
      cout << 0 << endl;
      return 0;
    }
  }
  for (int i = 0; i < n; i++) {
    if ((s[i] - '0') % 4 == 0) ans++;
  }
  for (int i = 0; i < n - 1; i++) {
    res1 = (s[i] - '0') % 4;
    res2 = (s[i + 1] - '0') % 4;
    if (((10 * res1) + res2) % 4 == 0) ans += i + 1;
  }
  cout << ans << endl;
  return 0;
}
