#include <bits/stdc++.h>
using namespace std;
int a, b, c, d, t;
string s;
int main() {
  cin >> s;
  a = s[0] - '0', b = s[1] - '0', c = s[3] - '0', d = s[4] - '0';
  for (int i = 0;; i++) {
    if (a == d && c == b) {
      return cout << t << '\n', false;
    } else {
      t++;
      if (d == 9)
        c++, d = 0;
      else
        d++;
      if (c == 6) b++, c = 0;
      if (b == 10) a++, b = 0;
      if (a == 2 && b == 4) a = b = 0;
    }
  }
  cout << t << '\n';
  return false;
}
