#include <bits/stdc++.h>
using namespace std;
bool isOk(string s) {
  assert(s.length() == 5);
  return s[0] == s[4] && s[1] == s[3];
}
string toh(int i) {
  string s = to_string(i);
  if (s.length() == 1) s = "0" + s;
  return s;
}
string increase(string s) {
  string h = s.substr(0, 2);
  string m = s.substr(3);
  int mi = stoi(m);
  int hi = stoi(h);
  mi++;
  if (mi == 60) {
    mi = 0;
    hi = (hi + 1) % 24;
  }
  h = toh(hi);
  m = toh(mi);
  return h + ":" + m;
}
int main() {
  string s;
  cin >> s;
  int count = 0;
  while (!isOk(s)) {
    s = increase(s);
    count++;
  }
  cout << count << endl;
  return 0;
}
