#include <bits/stdc++.h>
using namespace std;
bool is_palindrome(int h, int m) {
  int k = 10 * (m % 10) + (m / 10);
  if (h == k)
    return true;
  else
    return false;
}
int main() {
  string s;
  cin >> s;
  int ans = 0, hr = (10 * (s[0] - 48) + (s[1] - 48)),
      mi = (10 * int(s[3] - 48) + (s[4] - 48));
  for (int i = 0; i < 1500; i++) {
    if (is_palindrome(hr, mi)) {
      break;
    }
    if ((mi + 1) % 60 == 0) {
      hr = (hr + 1) % 24;
      mi = (mi + 1) % 60;
    } else
      mi = (mi + 1) % 60;
    ans++;
  }
  cout << ans << endl;
  return 0;
}
