#include <bits/stdc++.h>
using namespace std;
template <class Temp>
vector<Temp> read(long long int n) {
  vector<Temp> input;
  for (long long int i = 0; i < n; i++) {
    Temp k;
    cin >> k;
    input.push_back(k);
  }
  return input;
}
template <class Temp>
vector<vector<Temp>> read_matrix(long long int n, long long int m) {
  vector<vector<Temp>> input(n + 1, vector<Temp>(m + 1));
  for (long long int i = 1; i <= n; i++) {
    for (long long int j = 1; j <= m; j++) {
      Temp k;
      cin >> k;
      input[i][j] = k;
    }
  }
  return input;
}
template <class Temp>
void print(vector<long int> &v) {
  for (Temp a : v) {
    cout << a << " ";
  }
  cout << endl;
}
vector<long int> coor;
bool comparator(long int &i, long int &j) {
  return abs(coor[i]) > abs(coor[j]);
}
void solve() {
  string s;
  cin >> s;
  long int n = s.length();
  long long int ans = 0;
  if ((s[0] - '0') % 4 == 0) ans++;
  for (long int i = 1; i < n; i++) {
    int l = s[i] - '0';
    int t = s[i - 1] - '0';
    int num = 10 * t + l;
    if (num % 4 == 0) {
      ans += (i);
    }
    if (l % 4 == 0) {
      ans += 1;
    }
  }
  cout << ans << endl;
}
void test() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    solve();
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
}
