#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string s;
  cin >> s;
  int hr = (s[0] - '0') * 10 + (s[1] - '0');
  int mi = (s[3] - '0') * 10 + (s[4] - '0');
  for (int i = 0; i < 24 * 60; i++) {
    if (mi >= 60) {
      hr++;
      mi = 0;
    }
    if (hr >= 24) {
      hr = 0;
    }
    if (hr == (mi / 10) + (mi % 10) * 10) {
      cout << i << '\n';
      return 0;
    }
    mi++;
  }
  return 0;
}
